diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-02-25 01:04:24 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-02-25 01:04:24 +0100 |
commit | 9a1effcf29b27cc2e60b927c2d737b6cad0289b7 (patch) | |
tree | cd47309106493f869a7d7d5e9a43dcc99969dd4c /src/main/kotlin/pl | |
parent | c64b2c4b1f0c4e0e0d94d202715db4aaa47d9c65 (diff) | |
download | kvision-9a1effcf29b27cc2e60b927c2d737b6cad0289b7.tar.gz kvision-9a1effcf29b27cc2e60b927c2d737b6cad0289b7.tar.bz2 kvision-9a1effcf29b27cc2e60b927c2d737b6cad0289b7.zip |
Change enum classes names for better readability.
Diffstat (limited to 'src/main/kotlin/pl')
37 files changed, 236 insertions, 233 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt index 096cb26a..091c806a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt @@ -28,7 +28,7 @@ import pl.treksoft.kvision.utils.toHexString * Definitions of CSS units. */ @Suppress("EnumNaming", "EnumEntryName") -enum class UNIT(internal val unit: String) { +enum class Unit(internal val unit: String) { px("px"), pt("pt"), em("em"), @@ -49,7 +49,7 @@ enum class UNIT(internal val unit: String) { /** * Definitions of CSS border styles. */ -enum class BORDERSTYLE(internal val borderStyle: String) { +enum class BorderStyle(internal val borderStyle: String) { NONE("none"), HIDDEN("hidden"), DOTTED("dotted"), @@ -67,7 +67,7 @@ enum class BORDERSTYLE(internal val borderStyle: String) { /** * Definitions of CSS color names. */ -enum class COLOR(internal val color: String) { +enum class Col(internal val color: String) { ALICEBLUE("aliceblue"), ANTIQUEWHITE("antiquewhite"), AQUA("aqua"), @@ -214,7 +214,7 @@ enum class COLOR(internal val color: String) { /** * Definitions of CSS background size. */ -enum class BGSIZE(internal val size: String) { +enum class BgSize(internal val size: String) { COVER("cover"), CONTAIN("contain") } @@ -222,7 +222,7 @@ enum class BGSIZE(internal val size: String) { /** * Definitions of CSS background repeat options. */ -enum class BGREPEAT(internal val repeat: String) { +enum class BgRepeat(internal val repeat: String) { REPEAT("repeat"), REPEATX("repeat-x"), REPEATY("repeat-y"), @@ -232,7 +232,7 @@ enum class BGREPEAT(internal val repeat: String) { /** * Definitions of CSS background attachment options. */ -enum class BGATTACH(internal val attachment: String) { +enum class BgAttach(internal val attachment: String) { SCROLL("scroll"), FIXED("fixed"), LOCAL("local") @@ -241,7 +241,7 @@ enum class BGATTACH(internal val attachment: String) { /** * Definitions of CSS background origin options. */ -enum class BGORIGIN(internal val origin: String) { +enum class BgOrigin(internal val origin: String) { PADDING("padding-box"), BORDER("border-box"), CONTENT("content-box") @@ -250,7 +250,7 @@ enum class BGORIGIN(internal val origin: String) { /** * Definitions of CSS background clipping options. */ -enum class BGCLIP(internal val clip: String) { +enum class BgClip(internal val clip: String) { PADDING("padding-box"), BORDER("border-box"), CONTENT("content-box") @@ -259,7 +259,7 @@ enum class BGCLIP(internal val clip: String) { /** * Definitions of CSS position options. */ -enum class POSITION(internal val position: String) { +enum class Position(internal val position: String) { STATIC("static"), RELATIVE("relative"), FIXED("fixed"), @@ -271,7 +271,7 @@ enum class POSITION(internal val position: String) { * Type-safe definition of CSS border. */ class Border private constructor( - private val width: CssSize? = null, private val style: BORDERSTYLE? = null, + private val width: CssSize? = null, private val style: BorderStyle? = null, private val color: String? = null ) { /** @@ -279,7 +279,7 @@ class Border private constructor( * @param width width of the border * @param style style of the border */ - constructor(width: CssSize? = null, style: BORDERSTYLE? = null) : this(width, style, null) + constructor(width: CssSize? = null, style: BorderStyle? = null) : this(width, style, null) /** * Creates CSS Border with given width, style and color given in hex format. @@ -287,7 +287,7 @@ class Border private constructor( * @param style style of the border * @param color color in hex format */ - constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: Int) : this( + constructor(width: CssSize? = null, style: BorderStyle? = null, color: Int) : this( width, style, "#" + color.toHexString() ) @@ -298,7 +298,7 @@ class Border private constructor( * @param style style of the border * @param color color named constant */ - constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: COLOR) : this(width, style, color.color) + constructor(width: CssSize? = null, style: BorderStyle? = null, color: Col) : this(width, style, color.color) internal fun asString(): String { val w = width?.asString() @@ -320,7 +320,7 @@ class Color private constructor(private val color: String? = null) { * Creates CSS Color with color given with named constant. * @param color color named constant */ - constructor(color: COLOR) : this(color.color) + constructor(color: Col) : this(color.color) internal fun asString(): String { return color.orEmpty() @@ -334,9 +334,9 @@ class Background private constructor( private val color: String? = null, private val image: ResString? = null, private val positionX: CssSize? = null, private val positionY: CssSize? = null, private val sizeX: CssSize? = null, private val sizeY: CssSize? = null, - private val size: BGSIZE? = null, private val repeat: BGREPEAT? = null, - private val origin: BGORIGIN? = null, private val clip: BGCLIP? = null, - private val attachment: BGATTACH? = null + private val size: BgSize? = null, private val repeat: BgRepeat? = null, + private val origin: BgOrigin? = null, private val clip: BgClip? = null, + private val attachment: BgAttach? = null ) { /** * Creates CSS Background with given parameters. @@ -353,9 +353,9 @@ class Background private constructor( */ constructor( image: ResString? = null, positionX: CssSize? = null, positionY: CssSize? = null, - sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null, - repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, - attachment: BGATTACH? = null + sizeX: CssSize? = null, sizeY: CssSize? = null, size: BgSize? = null, + repeat: BgRepeat? = null, origin: BgOrigin? = null, clip: BgClip? = null, + attachment: BgAttach? = null ) : this( null, image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment @@ -378,9 +378,9 @@ class Background private constructor( constructor( color: Int, image: ResString? = null, positionX: CssSize? = null, positionY: CssSize? = null, - sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null, - repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, - attachment: BGATTACH? = null + sizeX: CssSize? = null, sizeY: CssSize? = null, size: BgSize? = null, + repeat: BgRepeat? = null, origin: BgOrigin? = null, clip: BgClip? = null, + attachment: BgAttach? = null ) : this( "#" + color.toHexString(), image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, @@ -402,10 +402,10 @@ class Background private constructor( * @param attachment attachment option of the background image */ constructor( - color: COLOR, image: ResString? = null, positionX: CssSize? = null, + color: Col, image: ResString? = null, positionX: CssSize? = null, positionY: CssSize? = null, sizeX: CssSize? = null, sizeY: CssSize? = null, - size: BGSIZE? = null, repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, - attachment: BGATTACH? = null + size: BgSize? = null, repeat: BgRepeat? = null, origin: BgOrigin? = null, clip: BgClip? = null, + attachment: BgAttach? = null ) : this( color.color, image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment diff --git a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt index 0215d967..37eb28c7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.core import pl.treksoft.kvision.utils.asString +import kotlin.Unit import kotlin.reflect.KProperty /** @@ -57,7 +58,7 @@ abstract class StyledComponent : Component { /** * CSS position of the current component. */ - var position: POSITION? by refreshOnUpdate() + var position: Position? by refreshOnUpdate() /** * Top edge of the current component. */ @@ -161,11 +162,11 @@ abstract class StyledComponent : Component { * * This property gives a convenient way to set the value of [color] property e.g.: * - * c.colorName = COLOR.GREEN + * c.colorName = Col.GREEN * * The value read from this property is always null. */ - var colorName: COLOR? + var colorName: Col? get() = null set(value) { color = if (value != null) Color(value) else null diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Types.kt b/src/main/kotlin/pl/treksoft/kvision/core/Types.kt index 0817b3ae..ef7abf06 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Types.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Types.kt @@ -41,4 +41,4 @@ typealias StringBoolPair = Pair<String, Boolean> /** * This type is used for defining CSS dimensions (width, heights, margins, paddings, etc.). */ -typealias CssSize = Pair<Int, UNIT> +typealias CssSize = Pair<Int, Unit> diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index bfa1fc40..c9c97187 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -38,6 +38,7 @@ import pl.treksoft.kvision.utils.snAttrs import pl.treksoft.kvision.utils.snClasses import pl.treksoft.kvision.utils.snOpt import pl.treksoft.kvision.utils.snStyle +import kotlin.Unit /** * Base widget class. The parent of all component classes. diff --git a/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt b/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt index 2616e77c..e5d9ebbd 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.core import com.github.snabbdom.VNode +import kotlin.Unit /** * This class allows to wrap a component into separately styled DIV element. diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index 1370f25a..3ea85d4a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -27,9 +27,9 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.CssSize import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair -import pl.treksoft.kvision.html.BUTTONSTYLE +import pl.treksoft.kvision.html.ButtonStyle import pl.treksoft.kvision.html.Button -import pl.treksoft.kvision.html.LISTTYPE +import pl.treksoft.kvision.html.ListType import pl.treksoft.kvision.html.Link import pl.treksoft.kvision.html.ListTag import pl.treksoft.kvision.html.TAG @@ -59,7 +59,7 @@ enum class DD(val option: String) { */ open class DropDown( text: String, elements: List<StringPair>? = null, icon: String? = null, - style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false, + style: ButtonStyle = ButtonStyle.DEFAULT, disabled: Boolean = false, classes: Set<String> = setOf() ) : SimplePanel(classes) { /** @@ -237,7 +237,7 @@ open class DropDown( */ fun Container.dropDown( text: String, elements: List<StringPair>? = null, icon: String? = null, - style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false, + style: ButtonStyle = ButtonStyle.DEFAULT, disabled: Boolean = false, classes: Set<String> = setOf(), init: (DropDown.() -> Unit)? = null ): DropDown { val dropDown = DropDown(text, elements, icon, style, disabled, classes).apply { init?.invoke(this) } @@ -248,7 +248,7 @@ open class DropDown( } internal class DropDownButton( - id: String, text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, + id: String, text: String, icon: String? = null, style: ButtonStyle = ButtonStyle.DEFAULT, disabled: Boolean = false, classes: Set<String> = setOf() ) : Button(text, icon, style, disabled, classes) { @@ -266,7 +266,7 @@ internal class DropDownButton( } internal class DropDownListTag(private val ariaId: String, classes: Set<String> = setOf()) : ListTag( - LISTTYPE.UL, null, + ListType.UL, null, false, classes ) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt index b8e9a1b4..2b974379 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt @@ -27,7 +27,7 @@ import kotlin.js.Date /** * Input controls sizes. */ -enum class INPUTSIZE(val className: String) { +enum class InputSize(val className: String) { LARGE("input-lg"), SMALL("input-sm") } @@ -43,7 +43,7 @@ interface FormControl : Component { /** * Input control size. */ - var size: INPUTSIZE? + var size: InputSize? /** * The actual input component. */ diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt index 75cb9c03..c13fe9f1 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt @@ -34,7 +34,7 @@ import kotlin.js.Json /** * Bootstrap form layout options. */ -enum class FORMTYPE(internal val formType: String) { +enum class FormType(internal val formType: String) { INLINE("form-inline"), HORIZONTAL("form-horizontal") } @@ -49,7 +49,7 @@ enum class FORMTYPE(internal val formType: String) { * @param modelFactory function transforming a Map<String, Any?> to a data model of class K */ open class FormPanel<K>( - private val type: FORMTYPE? = null, classes: Set<String> = setOf(), + private val type: FormType? = null, classes: Set<String> = setOf(), modelFactory: (Map<String, Any?>) -> K ) : SimplePanel(classes) { @@ -123,7 +123,7 @@ open class FormPanel<K>( validatorMessage: ((C) -> String?)? = null, validator: ((C) -> Boolean?)? = null ): FormPanel<K> { - if (type == FORMTYPE.HORIZONTAL) { + if (type == FormType.HORIZONTAL) { if (control is CheckBox || control is Radio) { control.addCssClass("col-sm-offset-2") control.addCssClass("col-sm-10") @@ -223,7 +223,7 @@ open class FormPanel<K>( * It takes the same parameters as the constructor of the built component. */ fun <K> Container.formPanel( - type: FORMTYPE? = null, classes: Set<String> = setOf(), + type: FormType? = null, classes: Set<String> = setOf(), modelFactory: (Map<String, Any?>) -> K ): FormPanel<K> { val panel = FormPanel(type, classes, modelFactory) 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 e76a1c7a..c274d999 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt @@ -34,7 +34,7 @@ import pl.treksoft.kvision.utils.SnOn /** * Checkbox style options. */ -enum class CHECKBOXSTYLE(internal val className: String) { +enum class CheckBoxStyle(internal val className: String) { DEFAULT("checkbox-default"), PRIMARY("checkbox-primary"), SUCCESS("checkbox-success"), @@ -107,7 +107,7 @@ open class CheckBox( /** * The style (one of Bootstrap standard colors) of the input. */ - var style: CHECKBOXSTYLE? by refreshOnUpdate() + var style: CheckBoxStyle? by refreshOnUpdate() /** * Determines if the checkbox is rendered as a circle. */ @@ -127,7 +127,7 @@ open class CheckBox( private val idc = "kv_form_checkbox_" + counter final override val input: CheckInput = CheckInput( - CHECKINPUTTYPE.CHECKBOX, value, + CheckInputType.CHECKBOX, value, setOf("styled") ).apply { id = idc } final override val flabel: FieldLabel = FieldLabel(idc, label, rich, classes = setOf()) 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 9e0c1fa9..a9e7b33d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt @@ -27,12 +27,12 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.form.INPUTSIZE +import pl.treksoft.kvision.form.InputSize /** * Type of the check input control (checkbox or radio). */ -enum class CHECKINPUTTYPE(internal val type: String) { +enum class CheckInputType(internal val type: String) { CHECKBOX("checkbox"), RADIO("radio") } @@ -46,7 +46,7 @@ enum class CHECKINPUTTYPE(internal val type: String) { * @param classes a set of CSS class names */ open class CheckInput( - type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, value: Boolean = false, + type: CheckInputType = CheckInputType.CHECKBOX, value: Boolean = false, classes: Set<String> = setOf() ) : Widget(classes) { @@ -93,7 +93,7 @@ open class CheckInput( /** * The size of the input. */ - var size: INPUTSIZE? by refreshOnUpdate() + var size: InputSize? by refreshOnUpdate() override fun render(): VNode { return render("input") @@ -159,7 +159,7 @@ open class CheckInput( * It takes the same parameters as the constructor of the built component. */ fun Container.checkInput( - type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, value: Boolean = false, + type: CheckInputType = CheckInputType.CHECKBOX, value: Boolean = false, classes: Set<String> = setOf(), init: (CheckInput.() -> Unit)? = null ): CheckInput { val checkInput = CheckInput(type, value, classes).apply { init?.invoke(this) } 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 0cf85fc5..a4dc851c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt @@ -34,7 +34,7 @@ import pl.treksoft.kvision.utils.SnOn /** * Radio style options. */ -enum class RADIOSTYLE(internal val className: String) { +enum class RadioStyle(internal val className: String) { DEFAULT("radio-default"), PRIMARY("radio-primary"), SUCCESS("radio-success"), @@ -117,7 +117,7 @@ open class Radio( /** * The style (one of Bootstrap standard colors) of the input. */ - var style: RADIOSTYLE? by refreshOnUpdate() + var style: RadioStyle? by refreshOnUpdate() /** * Determines if the radio button is rendered as a square. */ @@ -136,7 +136,7 @@ open class Radio( } private val idc = "kv_form_radio_" + counter - final override val input: CheckInput = CheckInput(CHECKINPUTTYPE.RADIO, value).apply { + final override val input: CheckInput = CheckInput(CheckInputType.RADIO, value).apply { this.id = idc this.extraValue = extraValue this.name = name 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 e5b04a47..8a4a84bd 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt @@ -27,7 +27,7 @@ import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.form.FieldLabel import pl.treksoft.kvision.form.HelpBlock -import pl.treksoft.kvision.form.INPUTSIZE +import pl.treksoft.kvision.form.InputSize import pl.treksoft.kvision.form.StringFormControl import pl.treksoft.kvision.form.select.Select import pl.treksoft.kvision.panel.SimplePanel @@ -87,7 +87,7 @@ open class RadioGroup( set(value) { flabel.rich = value } - override var size: INPUTSIZE? = null + override var size: InputSize? = null private val idc = "kv_form_radiogroup_" + Select.counter final override val input = Widget() diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt index 7fc91ddc..09d2fcdb 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt @@ -29,7 +29,7 @@ import pl.treksoft.kvision.utils.obj /** * HTTP protocol type for the AJAX call. */ -enum class HTTPTYPE(internal val type: String) { +enum class HttpType(internal val type: String) { GET("GET"), POST("POST") } @@ -37,7 +37,7 @@ enum class HTTPTYPE(internal val type: String) { /** * Data type for the AJAX call. */ -enum class DATATYPE(internal val type: String) { +enum class DataType(internal val type: String) { JSON("json"), JSONP("jsonp"), XML("xml"), @@ -77,8 +77,8 @@ enum class DATATYPE(internal val type: String) { */ data class AjaxOptions( val url: String, val preprocessData: (dynamic) -> dynamic, val beforeSend: ((JQueryXHR) -> dynamic)? = null, - val data: dynamic = null, val httpType: HTTPTYPE = HTTPTYPE.GET, - val dataType: DATATYPE = DATATYPE.JSON, val minLength: Int = 0, + val data: dynamic = null, val httpType: HttpType = HttpType.GET, + val dataType: DataType = DataType.JSON, val minLength: Int = 0, val cache: Boolean = true, val clearOnEmpty: Boolean = true, val clearOnError: Boolean = true, val emptyRequest: Boolean = false, val requestDelay: Int = AJAX_REQUEST_DELAY, val restoreOnError: Boolean = false 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 dd8fcabd..e94d7e2f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt @@ -28,8 +28,8 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.CssSize import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair -import pl.treksoft.kvision.form.INPUTSIZE -import pl.treksoft.kvision.html.BUTTONSTYLE +import pl.treksoft.kvision.form.InputSize +import pl.treksoft.kvision.html.ButtonStyle import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.utils.asString import pl.treksoft.kvision.utils.obj @@ -37,7 +37,7 @@ import pl.treksoft.kvision.utils.obj /** * Select width types. See [Bootstrap Select width](http://silviomoreto.github.io/bootstrap-select/examples/#width). */ -enum class SELECTWIDTHTYPE(internal val value: String) { +enum class SelectWidthType(internal val value: String) { AUTO("auto"), FIT("fit") } @@ -102,7 +102,7 @@ open class SelectInput( /** * The style of the select control. */ - var style: BUTTONSTYLE? by refreshOnUpdate() + var style: ButtonStyle? by refreshOnUpdate() /** * The width of the select control. */ @@ -110,7 +110,7 @@ open class SelectInput( /** * The width type of the select control. */ - var selectWidthType: SELECTWIDTHTYPE? by refreshOnUpdate() + var selectWidthType: SelectWidthType? by refreshOnUpdate() /** * Determines if an empty option is automatically generated. */ @@ -126,7 +126,7 @@ open class SelectInput( /** * The size of the input. */ - var size: INPUTSIZE? by refreshOnUpdate() + var size: InputSize? by refreshOnUpdate() init { setChildrenFromOptions() @@ -266,10 +266,10 @@ open class SelectInput( } val btnStyle = style?.className ?: "btn-default" when (size) { - INPUTSIZE.LARGE -> { + InputSize.LARGE -> { sn.add("data-style" to "$btnStyle btn-lg") } - INPUTSIZE.SMALL -> { + InputSize.SMALL -> { sn.add("data-style" to "$btnStyle btn-sm") } else -> { 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 3cd50473..7a6a535d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt @@ -46,8 +46,8 @@ import pl.treksoft.kvision.utils.SnOn */ open class Spinner( value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, - forceType: FORCETYPE = FORCETYPE.NONE, label: String? = null, + decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL, + forceType: ForceType = ForceType.NONE, label: String? = null, rich: Boolean = false ) : SimplePanel(setOf("form-group")), NumberFormControl { @@ -246,8 +246,8 @@ open class Spinner( */ fun Container.spinner( value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, - forceType: FORCETYPE = FORCETYPE.NONE, label: String? = null, + decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL, + forceType: ForceType = ForceType.NONE, label: String? = null, rich: Boolean = false, init: (Spinner.() -> Unit)? = null ): Spinner { val spinner = Spinner(value, min, max, step, decimals, buttonsType, forceType, label, rich).apply { 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 23c48a80..a0da7999 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -27,13 +27,13 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.form.INPUTSIZE +import pl.treksoft.kvision.form.InputSize import pl.treksoft.kvision.utils.obj /** * Spinner buttons layout types. */ -enum class BUTTONSTYPE { +enum class ButtonsType { NONE, HORIZONTAL, VERTICAL @@ -42,7 +42,7 @@ enum class BUTTONSTYPE { /** * Spinner force rounding types. */ -enum class FORCETYPE(internal val value: String) { +enum class ForceType(internal val value: String) { NONE("none"), ROUND("round"), FLOOR("floor"), @@ -68,19 +68,19 @@ internal const val DEFAULT_MAX = 100 @Suppress("TooManyFunctions") open class SpinnerInput( value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, - forceType: FORCETYPE = FORCETYPE.NONE, + decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL, + forceType: ForceType = ForceType.NONE, classes: Set<String> = setOf() ) : Widget(classes + "form-control") { init { this.addSurroundingCssClass("input-group") - if (buttonsType == BUTTONSTYPE.NONE) { + if (buttonsType == ButtonsType.NONE) { this.addSurroundingCssClass("kv-spinner-btn-none") } else { this.removeSurroundingCssClass("kv-spinner-btn-none") } - if (buttonsType == BUTTONSTYPE.VERTICAL) { + if (buttonsType == ButtonsType.VERTICAL) { this.addSurroundingCssClass("kv-spinner-btn-vertical") } else { this.removeSurroundingCssClass("kv-spinner-btn-vertical") @@ -152,7 +152,7 @@ open class SpinnerInput( /** * The size of the input. */ - var size: INPUTSIZE? by refreshOnUpdate() + var size: InputSize? by refreshOnUpdate() private var siblings: JQuery? = null @@ -270,7 +270,7 @@ open class SpinnerInput( } private fun getSettingsObj(): dynamic { - val verticalbuttons = buttonsType == BUTTONSTYPE.VERTICAL || buttonsType == BUTTONSTYPE.NONE + val verticalbuttons = buttonsType == ButtonsType.VERTICAL || buttonsType == ButtonsType.NONE return obj { this.min = min this.max = max @@ -291,8 +291,8 @@ open class SpinnerInput( */ fun Container.spinnerInput( value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, - forceType: FORCETYPE = FORCETYPE.NONE, classes: Set<String> = setOf(), + decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL, + forceType: ForceType = ForceType.NONE, classes: Set<String> = setOf(), init: (SpinnerInput.() -> Unit)? = null ): SpinnerInput { val spinnerInput = SpinnerInput(value, min, max, step, decimals, buttonsType, forceType, classes).apply { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt index c43f94ba..844e30ba 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt @@ -25,7 +25,7 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.form.INPUTSIZE +import pl.treksoft.kvision.form.InputSize /** * Base class for basic text components. @@ -85,7 +85,7 @@ abstract class AbstractTextInput( /** * The size of the input. */ - var size: INPUTSIZE? by refreshOnUpdate() + var size: InputSize? by refreshOnUpdate() override fun getSnClass(): List<StringBoolPair> { val cl = super.getSnClass().toMutableList() 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 e2f9ab93..995243c9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt @@ -32,7 +32,7 @@ import pl.treksoft.kvision.core.Container * @param rich determines if [label] can contain HTML code */ open class Password(value: String? = null, label: String? = null, rich: Boolean = false) : Text( - TEXTINPUTTYPE.PASSWORD, + TextInputType.PASSWORD, value, label, rich ) { companion object { 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 ac9d0d9b..fd53adff 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt @@ -33,7 +33,7 @@ import pl.treksoft.kvision.core.Container * @param rich determines if [label] can contain HTML code */ open class Text( - type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, + type: TextInputType = TextInputType.TEXT, value: String? = null, label: String? = null, rich: Boolean = false ) : AbstractText(label, rich) { @@ -70,7 +70,7 @@ open class Text( * It takes the same parameters as the constructor of the built component. */ fun Container.text( - type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, + type: TextInputType = TextInputType.TEXT, value: String? = null, label: String? = null, rich: Boolean = false, init: (Text.() -> Unit)? = null ): Text { val text = Text(type, value, label, rich).apply { init?.invoke(this) } 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 998bfb2c..bc6e178d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt @@ -28,7 +28,7 @@ import pl.treksoft.kvision.core.StringPair /** * Text input types. */ -enum class TEXTINPUTTYPE(internal val type: String) { +enum class TextInputType(internal val type: String) { TEXT("text"), PASSWORD("password"), EMAIL("email"), @@ -46,7 +46,7 @@ enum class TEXTINPUTTYPE(internal val type: String) { * @param value text input value * @param classes a set of CSS class names */ -open class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, classes: Set<String> = setOf()) : +open class TextInput(type: TextInputType = TextInputType.TEXT, value: String? = null, classes: Set<String> = setOf()) : AbstractTextInput(value, classes + "form-control") { /** @@ -85,7 +85,7 @@ 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> = setOf(), init: (TextInput.() -> Unit)? = null ): TextInput { val textInput = TextInput(type, value, classes).apply { init?.invoke(this) } 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 9fa87195..867a3aba 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -26,7 +26,7 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.form.INPUTSIZE +import pl.treksoft.kvision.form.InputSize import pl.treksoft.kvision.utils.obj import pl.treksoft.kvision.utils.toDateF import pl.treksoft.kvision.utils.toStringF @@ -88,7 +88,7 @@ open class DateTimeInput( /** * The size of the input. */ - var size: INPUTSIZE? by refreshOnUpdate() + var size: InputSize? by refreshOnUpdate() /** * Day of the week start. 0 (Sunday) to 6 (Saturday). */ diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt index e6f53737..84f7c309 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt @@ -32,7 +32,7 @@ import pl.treksoft.kvision.core.Widget /** * Button styles. */ -enum class BUTTONSTYLE(internal val className: String) { +enum class ButtonStyle(internal val className: String) { DEFAULT("btn-default"), PRIMARY("btn-primary"), SUCCESS("btn-success"), @@ -45,7 +45,7 @@ enum class BUTTONSTYLE(internal val className: String) { /** * Button sizes. */ -enum class BUTTONSIZE(internal val className: String) { +enum class ButtonSize(internal val className: String) { LARGE("btn-lg"), SMALL("btn-sm"), XSMALL("btn-xs") @@ -62,7 +62,7 @@ enum class BUTTONSIZE(internal val className: String) { * @param classes a set of CSS class names */ open class Button( - text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, + text: String, icon: String? = null, style: ButtonStyle = ButtonStyle.DEFAULT, disabled: Boolean = false, classes: Set<String> = setOf() ) : Widget(classes) { @@ -89,7 +89,7 @@ open class Button( /** * Button size. */ - var size: BUTTONSIZE? by refreshOnUpdate() + var size: ButtonSize? by refreshOnUpdate() /** * Determines if the button takes all the space horizontally. */ @@ -139,7 +139,7 @@ open class Button( * It takes the same parameters as the constructor of the built component. */ fun Container.button( - text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, + text: String, icon: String? = null, style: ButtonStyle = ButtonStyle.DEFAULT, disabled: Boolean = false, classes: Set<String> = setOf(), init: (Button.() -> Unit)? = null ): Button { val button = Button(text, icon, style, disabled, classes).apply { init?.invoke(this) } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt index ccfb3592..f71799ac 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt @@ -33,7 +33,7 @@ import pl.treksoft.kvision.core.Container open class Div( text: String, rich: Boolean = false, - align: ALIGN? = null, + align: Align? = null, classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null ) : @@ -47,7 +47,7 @@ open class Div( fun Container.div( text: String, rich: Boolean = false, - align: ALIGN? = null, + align: Align? = null, classes: Set<String> = setOf(), init: (Div.() -> Unit)? = null ): Div { diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt index ac7829e8..61733fb3 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt @@ -31,7 +31,7 @@ import pl.treksoft.kvision.core.Widget /** * Image shapes. */ -enum class IMAGESHAPE(internal val className: String) { +enum class ImageShape(internal val className: String) { ROUNDED("img-rounded"), CIRCLE("img-circle"), THUMBNAIL("img-thumbnail") @@ -49,7 +49,7 @@ enum class IMAGESHAPE(internal val className: String) { * @param classes a set of CSS class names */ open class Image( - src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGESHAPE? = null, + src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null, centered: Boolean = false, classes: Set<String> = setOf() ) : Widget(classes) { /** @@ -107,7 +107,7 @@ open class Image( * It takes the same parameters as the constructor of the built component. */ fun Container.image( - src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGESHAPE? = null, + src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null, centered: Boolean = false, classes: Set<String> = setOf(), init: (Image.() -> Unit)? = null ): Image { val image = Image(src, alt, responsive, shape, centered, classes).apply { init?.invoke(this) } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt index 185d2eea..fb49cd62 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt @@ -32,7 +32,7 @@ import pl.treksoft.kvision.panel.SimplePanel /** * HTML list types. */ -enum class LISTTYPE(internal val tagName: String) { +enum class ListType(internal val tagName: String) { UL("ul"), OL("ol"), UNSTYLED("ul"), @@ -55,7 +55,7 @@ enum class LISTTYPE(internal val tagName: String) { * @param init an initializer extension function */ open class ListTag( - type: LISTTYPE, elements: List<String>? = null, rich: Boolean = false, + type: ListType, elements: List<String>? = null, rich: Boolean = false, classes: Set<String> = setOf(), init: (ListTag.() -> Unit)? = null ) : SimplePanel(classes) { /** @@ -78,10 +78,10 @@ open class ListTag( override fun render(): VNode { val childrenElements = when (type) { - LISTTYPE.UL, LISTTYPE.OL, LISTTYPE.UNSTYLED, LISTTYPE.INLINE -> elements?.map { el -> + ListType.UL, ListType.OL, ListType.UNSTYLED, ListType.INLINE -> elements?.map { el -> element("li", el, rich) } - LISTTYPE.DL, LISTTYPE.DL_HORIZ -> elements?.mapIndexed { index, el -> + ListType.DL, ListType.DL_HORIZ -> elements?.mapIndexed { index, el -> element(if (index % 2 == 0) "dt" else "dd", el, rich) } }?.toTypedArray() @@ -95,14 +95,14 @@ open class ListTag( override fun childrenVNodes(): Array<VNode> { val childrenElements = children.filter { it.visible } val res = when (type) { - LISTTYPE.UL, LISTTYPE.OL, LISTTYPE.UNSTYLED, LISTTYPE.INLINE -> childrenElements.map { v -> + ListType.UL, ListType.OL, ListType.UNSTYLED, ListType.INLINE -> childrenElements.map { v -> if (v is Tag && v.type == TAG.LI) { v.renderVNode() } else { h("li", arrayOf(v.renderVNode())) } } - LISTTYPE.DL, LISTTYPE.DL_HORIZ -> childrenElements.mapIndexed { index, v -> + ListType.DL, ListType.DL_HORIZ -> childrenElements.mapIndexed { index, v -> if (v is Tag && v.type == TAG.LI) { v.renderVNode() } else { @@ -125,9 +125,9 @@ open class ListTag( val cl = super.getSnClass().toMutableList() @Suppress("NON_EXHAUSTIVE_WHEN") when (type) { - LISTTYPE.UNSTYLED -> cl.add("list-unstyled" to true) - LISTTYPE.INLINE -> cl.add("list-inline" to true) - LISTTYPE.DL_HORIZ -> cl.add("dl-horizontal" to true) + ListType.UNSTYLED -> cl.add("list-unstyled" to true) + ListType.INLINE -> cl.add("list-inline" to true) + ListType.DL_HORIZ -> cl.add("dl-horizontal" to true) } return cl } @@ -139,7 +139,7 @@ open class ListTag( * It takes the same parameters as the constructor of the built component. */ fun Container.listTag( - type: LISTTYPE, elements: List<String>? = null, rich: Boolean = false, + type: ListType, elements: List<String>? = null, rich: Boolean = false, classes: Set<String> = setOf(), init: (ListTag.() -> Unit)? = null ): ListTag { val listTag = ListTag(type, elements, rich, classes, init) diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index a3b7f231..33ef2cb7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -71,7 +71,7 @@ enum class TAG(internal val tagName: String) { /** * CSS align attributes. */ -enum class ALIGN(val className: String) { +enum class Align(val className: String) { LEFT("text-left"), CENTER("text-center"), RIGHT("text-right"), @@ -91,7 +91,7 @@ enum class ALIGN(val className: String) { * @param init an initializer extension function */ open class Tag( - type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN? = null, + type: TAG, text: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null ) : SimplePanel(classes) { @@ -144,7 +144,7 @@ open class Tag( * It takes the same parameters as the constructor of the built component. */ fun Container.tag( - type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN? = null, + type: TAG, text: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null ): Tag { val tag = Tag(type, text, rich, align, classes, init) diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt index 8d83ee51..de5bcd3b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt @@ -22,8 +22,8 @@ package pl.treksoft.kvision.modal import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.html.ALIGN -import pl.treksoft.kvision.html.BUTTONSTYLE +import pl.treksoft.kvision.html.Align +import pl.treksoft.kvision.html.ButtonStyle import pl.treksoft.kvision.html.Button import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag @@ -43,7 +43,7 @@ import pl.treksoft.kvision.utils.ENTER_KEY */ open class Alert( caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + align: Align? = null, size: ModalSize? = null, animation: Boolean = true, private val callback: (() -> Unit)? = null ) : Modal(caption, true, size, animation) { @@ -76,7 +76,7 @@ open class Alert( init { body.add(content) - val okButton = Button("OK", "ok", BUTTONSTYLE.PRIMARY) + val okButton = Button("OK", "ok", ButtonStyle.PRIMARY) okButton.setEventListener { click = { hide() @@ -112,7 +112,7 @@ open class Alert( @Suppress("LongParameterList") fun show( caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + align: Align? = null, size: ModalSize? = null, animation: Boolean = true, callback: (() -> Unit)? = null ) { Alert(caption, text, rich, align, size, animation, callback).show() diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt index a3bb8d77..55310d50 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt @@ -21,8 +21,8 @@ */ package pl.treksoft.kvision.modal -import pl.treksoft.kvision.html.ALIGN -import pl.treksoft.kvision.html.BUTTONSTYLE +import pl.treksoft.kvision.html.Align +import pl.treksoft.kvision.html.ButtonStyle import pl.treksoft.kvision.html.Button import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag @@ -43,7 +43,7 @@ import pl.treksoft.kvision.html.Tag */ open class Confirm( caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + align: Align? = null, size: ModalSize? = null, animation: Boolean = true, cancelVisible: Boolean = false, private val noCallback: (() -> Unit)? = null, private val yesCallback: (() -> Unit)? = null @@ -96,7 +96,7 @@ open class Confirm( } } this.addButton(noButton) - val yesButton = Button("Yes", "ok", BUTTONSTYLE.PRIMARY) + val yesButton = Button("Yes", "ok", ButtonStyle.PRIMARY) yesButton.setEventListener { click = { hide() @@ -133,7 +133,7 @@ open class Confirm( @Suppress("LongParameterList") fun show( caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + align: Align? = null, size: ModalSize? = null, animation: Boolean = true, cancelVisible: Boolean = false, noCallback: (() -> Unit)? = null, yesCallback: (() -> Unit)? = null ) { diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index d9cd0e8e..d4addf24 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -36,7 +36,7 @@ import pl.treksoft.kvision.utils.obj /** * Modal window sizes. */ -enum class MODALSIZE(val className: String) { +enum class ModalSize(val className: String) { LARGE("modal-lg"), SMALL("modal-sm") } @@ -56,7 +56,7 @@ enum class MODALSIZE(val className: String) { @Suppress("TooManyFunctions") open class Modal( caption: String? = null, closeButton: Boolean = true, - size: MODALSIZE? = null, animation: Boolean = true, private val escape: Boolean = true, + size: ModalSize? = null, animation: Boolean = true, private val escape: Boolean = true, classes: Set<String> = setOf(), init: (Modal.() -> Unit)? = null ) : SimplePanel(classes) { @@ -251,7 +251,7 @@ open class Modal( * @constructor * @param size modal window size */ -internal class ModalDialog(size: MODALSIZE?) : SimplePanel(setOf("modal-dialog")) { +internal class ModalDialog(size: ModalSize?) : SimplePanel(setOf("modal-dialog")) { /** * Modal window size. diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt index b605cf56..3a5f25f2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt @@ -27,7 +27,7 @@ import pl.treksoft.kvision.core.Container /** * Dock layout directions. */ -enum class SIDE { +enum class Side { LEFT, RIGHT, CENTER, @@ -75,14 +75,14 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * Internal property. */ protected val mainContainer = FlexPanel( - direction = FLEXDIR.COLUMN, justify = FLEXJUSTIFY.SPACEBETWEEN, - alignItems = FLEXALIGNITEMS.STRETCH + direction = FlexDir.COLUMN, justify = FlexJustify.SPACEBETWEEN, + alignItems = FlexAlignItems.STRETCH ) /** * @suppress * Internal property. */ - protected val subContainer = FlexPanel(justify = FLEXJUSTIFY.SPACEBETWEEN, alignItems = FLEXALIGNITEMS.CENTER) + protected val subContainer = FlexPanel(justify = FlexJustify.SPACEBETWEEN, alignItems = FlexAlignItems.CENTER) init { this.addInternal(mainContainer) @@ -98,39 +98,39 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * @return current container */ @Suppress("MagicNumber") - open fun add(child: Component, position: SIDE): DockPanel { + open fun add(child: Component, position: Side): DockPanel { when (position) { - SIDE.UP -> { + Side.UP -> { upComponent?.let { mainContainer.remove(it) } upComponent = child - mainContainer.add(child, 1, alignSelf = FLEXALIGNITEMS.CENTER) + mainContainer.add(child, 1, alignSelf = FlexAlignItems.CENTER) } - SIDE.CENTER -> { + Side.CENTER -> { centerComponent?.let { subContainer.remove(it) } centerComponent = child subContainer.add(child, 2) } - SIDE.LEFT -> { + Side.LEFT -> { leftComponent?.let { subContainer.remove(it) } leftComponent = child subContainer.add(child, 1) } - SIDE.RIGHT -> { + Side.RIGHT -> { rightComponent?.let { subContainer.remove(it) } rightComponent = child subContainer.add(child, 3) } - SIDE.DOWN -> { + Side.DOWN -> { downComponent?.let { mainContainer.remove(it) } downComponent = child - mainContainer.add(child, 3, alignSelf = FLEXALIGNITEMS.CENTER) + mainContainer.add(child, 3, alignSelf = FlexAlignItems.CENTER) } } return this } override fun add(child: Component): DockPanel { - return this.add(child, SIDE.CENTER) + return this.add(child, Side.CENTER) } override fun addAll(children: List<Component>): DockPanel { @@ -139,11 +139,11 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit } override fun remove(child: Component): DockPanel { - if (child == leftComponent) removeAt(SIDE.LEFT) - if (child == centerComponent) removeAt(SIDE.CENTER) - if (child == rightComponent) removeAt(SIDE.RIGHT) - if (child == upComponent) removeAt(SIDE.UP) - if (child == downComponent) removeAt(SIDE.DOWN) + if (child == leftComponent) removeAt(Side.LEFT) + if (child == centerComponent) removeAt(Side.CENTER) + if (child == rightComponent) removeAt(Side.RIGHT) + if (child == upComponent) removeAt(Side.UP) + if (child == downComponent) removeAt(Side.DOWN) return this } @@ -152,25 +152,25 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * @param position position in the dock * @return current container */ - open fun removeAt(position: SIDE): DockPanel { + open fun removeAt(position: Side): DockPanel { when (position) { - SIDE.UP -> { + Side.UP -> { upComponent?.let { mainContainer.remove(it) } upComponent = null } - SIDE.CENTER -> { + Side.CENTER -> { centerComponent?.let { subContainer.remove(it) } centerComponent = null } - SIDE.LEFT -> { + Side.LEFT -> { leftComponent?.let { subContainer.remove(it) } leftComponent = null } - SIDE.RIGHT -> { + Side.RIGHT -> { rightComponent?.let { subContainer.remove(it) } rightComponent = null } - SIDE.DOWN -> { + Side.DOWN -> { downComponent?.let { mainContainer.remove(it) } downComponent = null } @@ -179,11 +179,11 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit } override fun removeAll(): DockPanel { - removeAt(SIDE.LEFT) - removeAt(SIDE.CENTER) - removeAt(SIDE.RIGHT) - removeAt(SIDE.UP) - removeAt(SIDE.DOWN) + removeAt(Side.LEFT) + removeAt(Side.CENTER) + removeAt(Side.RIGHT) + removeAt(Side.UP) + removeAt(Side.DOWN) return this } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt index 4591a747..d22a285b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt @@ -31,7 +31,7 @@ import pl.treksoft.kvision.utils.px /** * CSS flexbox directions. */ -enum class FLEXDIR(internal val dir: String) { +enum class FlexDir(internal val dir: String) { ROW("row"), ROWREV("row-reverse"), COLUMN("column"), @@ -41,7 +41,7 @@ enum class FLEXDIR(internal val dir: String) { /** * CSS flexbox wrap modes. */ -enum class FLEXWRAP(internal val wrap: String) { +enum class FlexWrap(internal val wrap: String) { NOWRAP("nowrap"), WRAP("wrap"), WRAPREV("wrap-reverse") @@ -50,7 +50,7 @@ enum class FLEXWRAP(internal val wrap: String) { /** * CSS flexbox justification options. */ -enum class FLEXJUSTIFY(internal val justify: String) { +enum class FlexJustify(internal val justify: String) { FLEXSTART("flex-start"), FLEXEND("flex-end"), CENTER("center"), @@ -62,7 +62,7 @@ enum class FLEXJUSTIFY(internal val justify: String) { /** * CSS flexbox alignments options. */ -enum class FLEXALIGNITEMS(internal val alignItems: String) { +enum class FlexAlignItems(internal val alignItems: String) { FLEXSTART("flex-start"), FLEXEND("flex-end"), CENTER("center"), @@ -73,7 +73,7 @@ enum class FLEXALIGNITEMS(internal val alignItems: String) { /** * CSS flexbox content alignment options. */ -enum class FLEXALIGNCONTENT(internal val alignContent: String) { +enum class FlexAlignContent(internal val alignContent: String) { FLEXSTART("flex-start"), FLEXEND("flex-end"), CENTER("center"), @@ -96,8 +96,8 @@ enum class FLEXALIGNCONTENT(internal val alignContent: String) { * @param init an initializer extension function */ open class FlexPanel( - direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify: FLEXJUSTIFY? = null, - alignItems: FLEXALIGNITEMS? = null, alignContent: FLEXALIGNCONTENT? = null, + direction: FlexDir? = null, wrap: FlexWrap? = null, justify: FlexJustify? = null, + alignItems: FlexAlignItems? = null, alignContent: FlexAlignContent? = null, spacing: Int? = null, classes: Set<String> = setOf(), init: (FlexPanel.() -> Unit)? = null ) : SimplePanel(classes) { @@ -144,7 +144,7 @@ open class FlexPanel( @Suppress("LongParameterList") fun add( child: Component, order: Int? = null, grow: Int? = null, shrink: Int? = null, - basis: Int? = null, alignSelf: FLEXALIGNITEMS? = null, classes: Set<String> = setOf() + basis: Int? = null, alignSelf: FlexAlignItems? = null, classes: Set<String> = setOf() ): FlexPanel { val wrapper = FlexWrapper(child, order, grow, shrink, basis, alignSelf, classes) addInternal(applySpacing(wrapper)) @@ -162,9 +162,9 @@ open class FlexPanel( wrapper.marginLeft = null spacing?.let { when (direction) { - FLEXDIR.COLUMN -> wrapper.marginBottom = it.px - FLEXDIR.ROWREV -> wrapper.marginLeft = it.px - FLEXDIR.COLUMNREV -> wrapper.marginTop = it.px + FlexDir.COLUMN -> wrapper.marginBottom = it.px + FlexDir.ROWREV -> wrapper.marginLeft = it.px + FlexDir.COLUMNREV -> wrapper.marginTop = it.px else -> wrapper.marginRight = it.px } } @@ -226,8 +226,8 @@ open class FlexPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.flexPanel( - direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify: FLEXJUSTIFY? = null, - alignItems: FLEXALIGNITEMS? = null, alignContent: FLEXALIGNCONTENT? = null, + direction: FlexDir? = null, wrap: FlexWrap? = null, justify: FlexJustify? = null, + alignItems: FlexAlignItems? = null, alignContent: FlexAlignContent? = null, spacing: Int? = null, classes: Set<String> = setOf(), init: (FlexPanel.() -> Unit)? = null ): FlexPanel { val flexPanel = FlexPanel(direction, wrap, justify, alignItems, alignContent, spacing, classes, init) @@ -243,7 +243,7 @@ open class FlexPanel( internal class FlexWrapper( delegate: Component, private val order: Int? = null, private val grow: Int? = null, private val shrink: Int? = null, private val basis: Int? = null, - private val alignSelf: FLEXALIGNITEMS? = null, + private val alignSelf: FlexAlignItems? = null, classes: Set<String> = setOf() ) : WidgetWrapper(delegate, classes) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt index 10e956be..1f5efbb4 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt @@ -29,7 +29,7 @@ import pl.treksoft.kvision.core.WidgetWrapper /** * CSS grid justification options. */ -enum class GRIDJUSTIFY(internal val justify: String) { +enum class GridJustify(internal val justify: String) { START("start"), END("end"), CENTER("center"), @@ -39,7 +39,7 @@ enum class GRIDJUSTIFY(internal val justify: String) { /** * CSS grid alignment options. */ -enum class GRIDALIGN(internal val align: String) { +enum class GridAlign(internal val align: String) { START("start"), END("end"), CENTER("center"), @@ -49,7 +49,7 @@ enum class GRIDALIGN(internal val align: String) { /** * CSS grid content justification options. */ -enum class GRIDJUSTIFYCONTENT(internal val justifyContent: String) { +enum class GridJustifyContent(internal val justifyContent: String) { START("start"), END("end"), CENTER("center"), @@ -62,7 +62,7 @@ enum class GRIDJUSTIFYCONTENT(internal val justifyContent: String) { /** * CSS grid content alignment options. */ -enum class GRIDALIGNCONTENT(internal val alignContent: String) { +enum class GridAlignContent(internal val alignContent: String) { START("start"), END("end"), CENTER("center"), @@ -75,7 +75,7 @@ enum class GRIDALIGNCONTENT(internal val alignContent: String) { /** * CSS grid flow options. */ -enum class GRIDFLOW(internal val flow: String) { +enum class GridFlow(internal val flow: String) { ROW("row"), COLUMN("column"), ROWDENSE("row dense"), @@ -102,11 +102,11 @@ enum class GRIDFLOW(internal val flow: String) { * @param init an initializer extension function */ open class GridPanel( - autoColumns: String? = null, autoRows: String? = null, autoFlow: GRIDFLOW? = null, + autoColumns: String? = null, autoRows: String? = null, autoFlow: GridFlow? = null, templateColumns: String? = null, templateRows: String? = null, templateAreas: List<String>? = null, - columnGap: Int? = null, rowGap: Int? = null, justifyItems: GRIDJUSTIFY? = null, - alignItems: GRIDALIGN? = null, justifyContent: GRIDJUSTIFYCONTENT? = null, - alignContent: GRIDALIGNCONTENT? = null, classes: Set<String> = setOf(), init: (GridPanel.() -> Unit)? = null + columnGap: Int? = null, rowGap: Int? = null, justifyItems: GridJustify? = null, + alignItems: GridAlign? = null, justifyContent: GridJustifyContent? = null, + alignContent: GridAlignContent? = null, classes: Set<String> = setOf(), init: (GridPanel.() -> Unit)? = null ) : SimplePanel(classes) { /** @@ -179,8 +179,8 @@ open class GridPanel( @Suppress("LongParameterList") fun add( child: Component, columnStart: Int? = null, rowStart: Int? = null, - columnEnd: String? = null, rowEnd: String? = null, area: String? = null, justifySelf: GRIDJUSTIFY? = null, - alignSelf: GRIDALIGN? = null, classes: Set<String> = setOf() + columnEnd: String? = null, rowEnd: String? = null, area: String? = null, justifySelf: GridJustify? = null, + alignSelf: GridAlign? = null, classes: Set<String> = setOf() ): GridPanel { addInternal(GridWrapper(child, columnStart, rowStart, columnEnd, rowEnd, area, justifySelf, alignSelf, classes)) return this @@ -263,11 +263,11 @@ open class GridPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.gridPanel( - autoColumns: String? = null, autoRows: String? = null, autoFlow: GRIDFLOW? = null, + autoColumns: String? = null, autoRows: String? = null, autoFlow: GridFlow? = null, templateColumns: String? = null, templateRows: String? = null, templateAreas: List<String>? = null, - columnGap: Int? = null, rowGap: Int? = null, justifyItems: GRIDJUSTIFY? = null, - alignItems: GRIDALIGN? = null, justifyContent: GRIDJUSTIFYCONTENT? = null, - alignContent: GRIDALIGNCONTENT? = null, classes: Set<String> = setOf(), init: (GridPanel.() -> Unit)? = null + columnGap: Int? = null, rowGap: Int? = null, justifyItems: GridJustify? = null, + alignItems: GridAlign? = null, justifyContent: GridJustifyContent? = null, + alignContent: GridAlignContent? = null, classes: Set<String> = setOf(), init: (GridPanel.() -> Unit)? = null ): GridPanel { val gridPanel = GridPanel( autoColumns, autoRows, autoFlow, templateColumns, templateRows, templateAreas, @@ -282,8 +282,8 @@ open class GridPanel( class GridWrapper( delegate: Component, private val columnStart: Int? = null, private val rowStart: Int? = null, private val columnEnd: String? = null, private val rowEnd: String? = null, - private val area: String? = null, private val justifySelf: GRIDJUSTIFY? = null, - private val alignSelf: GRIDALIGN? = null, + private val area: String? = null, private val justifySelf: GridJustify? = null, + private val alignSelf: GridAlign? = null, classes: Set<String> = setOf() ) : WidgetWrapper(delegate, classes) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt index d0176481..0700e88a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt @@ -37,7 +37,7 @@ import pl.treksoft.kvision.core.Container * @param init an initializer extension function */ open class HPanel( - wrap: FLEXWRAP? = null, justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, spacing: Int? = null, + wrap: FlexWrap? = null, justify: FlexJustify? = null, alignItems: FlexAlignItems? = null, spacing: Int? = null, classes: Set<String> = setOf(), init: (HPanel.() -> Unit)? = null ) : FlexPanel( null, @@ -55,9 +55,9 @@ open class HPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.hPanel( - wrap: FLEXWRAP? = null, - justify: FLEXJUSTIFY? = null, - alignItems: FLEXALIGNITEMS? = null, + wrap: FlexWrap? = null, + justify: FlexJustify? = null, + alignItems: FlexAlignItems? = null, spacing: Int? = null, classes: Set<String> = setOf(), init: (HPanel.() -> Unit)? = null diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt index a5b3d577..4bbca9dd 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt @@ -24,14 +24,14 @@ package pl.treksoft.kvision.panel import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.WidgetWrapper -import pl.treksoft.kvision.html.ALIGN +import pl.treksoft.kvision.html.Align import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag /** * Bootstrap grid sizes. */ -enum class GRIDSIZE(internal val size: String) { +enum class GridSize(internal val size: String) { XS("xs"), SM("sm"), MD("md"), @@ -46,7 +46,7 @@ internal data class WidgetParam(val widget: Component, val size: Int, val offset * The container with support for Bootstrap responsive grid layout. * * @constructor - * @param gridsize grid size + * @param gridSize grid size * @param rows number of rows * @param cols number of columns * @param align text align of grid cells @@ -54,8 +54,8 @@ internal data class WidgetParam(val widget: Component, val size: Int, val offset * @param init an initializer extension function */ open class ResponsiveGridPanel( - private val gridsize: GRIDSIZE = GRIDSIZE.MD, - private var rows: Int = 0, private var cols: Int = 0, align: ALIGN? = null, + private val gridSize: GridSize = GridSize.MD, + private var rows: Int = 0, private var cols: Int = 0, align: Align? = null, classes: Set<String> = setOf(), init: (ResponsiveGridPanel.() -> Unit)? = null ) : SimplePanel(classes) { @@ -135,8 +135,8 @@ open class ResponsiveGridPanel( (0 until cols).map { row[it] }.forEach { wp -> if (auto) { val widget = wp?.widget?.let { - WidgetWrapper(it, setOf("col-" + gridsize.size + "-" + num)) - } ?: Tag(TAG.DIV, classes = setOf("col-" + gridsize.size + "-" + num)) + WidgetWrapper(it, setOf("col-" + gridSize.size + "-" + num)) + } ?: Tag(TAG.DIV, classes = setOf("col-" + gridSize.size + "-" + num)) align?.let { widget.addCssClass(it.className) } @@ -144,9 +144,9 @@ open class ResponsiveGridPanel( } else { if (wp != null) { val s = if (wp.size > 0) wp.size else num - val widget = WidgetWrapper(wp.widget, setOf("col-" + gridsize.size + "-" + s)) + val widget = WidgetWrapper(wp.widget, setOf("col-" + gridSize.size + "-" + s)) if (wp.offset > 0) { - widget.addCssClass("col-" + gridsize.size + "-offset-" + wp.offset) + widget.addCssClass("col-" + gridSize.size + "-offset-" + wp.offset) } align?.let { widget.addCssClass(it.className) @@ -173,11 +173,11 @@ open class ResponsiveGridPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.responsiveGridPanel( - gridsize: GRIDSIZE = GRIDSIZE.MD, - rows: Int = 0, cols: Int = 0, align: ALIGN? = null, + gridSize: GridSize = GridSize.MD, + rows: Int = 0, cols: Int = 0, align: Align? = null, classes: Set<String> = setOf(), init: (ResponsiveGridPanel.() -> Unit)? = null ): ResponsiveGridPanel { - val responsiveGridPanel = ResponsiveGridPanel(gridsize, rows, cols, align, classes, init) + val responsiveGridPanel = ResponsiveGridPanel(gridSize, rows, cols, align, classes, init) this.add(responsiveGridPanel) return responsiveGridPanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index d5e4cb03..423b1cde 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -26,7 +26,7 @@ import pl.treksoft.jquery.JQuery import pl.treksoft.jquery.JQueryEventObject import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StyledComponent -import pl.treksoft.kvision.core.UNIT +import pl.treksoft.kvision.core.Unit import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.utils.obj @@ -34,7 +34,7 @@ import pl.treksoft.kvision.utils.obj /** * Split panel direction. */ -enum class DIRECTION(internal val dir: String) { +enum class Direction(internal val dir: String) { HORIZONTAL("horizontal"), VERTICAL("vertical") } @@ -51,8 +51,8 @@ enum class DIRECTION(internal val dir: String) { * @param init an initializer extension function */ open class SplitPanel( - private val direction: DIRECTION = DIRECTION.VERTICAL, - classes: Set<String> = setOf(), init: (SplitPanel.() -> Unit)? = null + private val direction: Direction = Direction.VERTICAL, + classes: Set<String> = setOf(), init: (SplitPanel.() -> kotlin.Unit)? = null ) : SimplePanel(classes + ("splitpanel-" + direction.dir)) { @Suppress("LeakingThis") @@ -66,8 +66,8 @@ open class SplitPanel( @Suppress("UnsafeCastFromDynamic") internal fun afterInsertSplitter() { if (children.size == 2) { - val horizontal = direction == DIRECTION.HORIZONTAL - val px = UNIT.px + val horizontal = direction == Direction.HORIZONTAL + val px = Unit.px val self = this children[0].getElementJQueryD().resizable(obj { handleSelector = "#" + splitter.id @@ -106,8 +106,8 @@ open class SplitPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.splitPanel( - direction: DIRECTION = DIRECTION.VERTICAL, - classes: Set<String> = setOf(), init: (SplitPanel.() -> Unit)? = null + direction: Direction = Direction.VERTICAL, + classes: Set<String> = setOf(), init: (SplitPanel.() -> kotlin.Unit)? = null ): SplitPanel { val splitPanel = SplitPanel(direction, classes, init) this.add(splitPanel) @@ -116,7 +116,7 @@ open class SplitPanel( } } -internal class Splitter(private val splitPanel: SplitPanel, direction: DIRECTION) : Tag( +internal class Splitter(private val splitPanel: SplitPanel, direction: Direction) : Tag( TAG.DIV, classes = setOf("splitter-" + direction.dir) ) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt index c2cb602b..eb9c138e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt @@ -36,10 +36,10 @@ import pl.treksoft.kvision.core.Container * @param init an initializer extension function */ open class VPanel( - justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, spacing: Int? = null, + justify: FlexJustify? = null, alignItems: FlexAlignItems? = null, spacing: Int? = null, classes: Set<String> = setOf(), init: (VPanel.() -> Unit)? = null ) : FlexPanel( - FLEXDIR.COLUMN, + FlexDir.COLUMN, null, justify, alignItems, null, spacing, classes ) { init { @@ -54,7 +54,7 @@ open class VPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.vPanel( - justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, spacing: Int? = null, + justify: FlexJustify? = null, alignItems: FlexAlignItems? = null, spacing: Int? = null, classes: Set<String> = setOf(), init: (VPanel.() -> Unit)? = null ): VPanel { val vpanel = VPanel(justify, alignItems, spacing, classes, init) diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt index 335e0415..ec7c4961 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt @@ -25,7 +25,7 @@ package pl.treksoft.kvision.utils import pl.treksoft.kvision.KVManager import pl.treksoft.kvision.core.CssSize -import pl.treksoft.kvision.core.UNIT +import pl.treksoft.kvision.core.Unit import kotlin.js.Date /** @@ -33,7 +33,7 @@ import kotlin.js.Date */ val Int.px: CssSize get() { - return Pair(this, UNIT.px) + return Pair(this, Unit.px) } /** @@ -41,7 +41,7 @@ val Int.px: CssSize */ val Int.em: CssSize get() { - return Pair(this, UNIT.em) + return Pair(this, Unit.em) } /** @@ -49,7 +49,7 @@ val Int.em: CssSize */ val Int.pt: CssSize get() { - return Pair(this, UNIT.pt) + return Pair(this, Unit.pt) } /** @@ -57,7 +57,7 @@ val Int.pt: CssSize */ val Int.perc: CssSize get() { - return Pair(this, UNIT.perc) + return Pair(this, Unit.perc) } /** @@ -65,7 +65,7 @@ val Int.perc: CssSize */ val Int.rem: CssSize get() { - return Pair(this, UNIT.rem) + return Pair(this, Unit.rem) } /** @@ -73,7 +73,7 @@ val Int.rem: CssSize */ val Int.ch: CssSize get() { - return Pair(this, UNIT.ch) + return Pair(this, Unit.ch) } /** @@ -81,7 +81,7 @@ val Int.ch: CssSize */ val Int.cm: CssSize get() { - return Pair(this, UNIT.cm) + return Pair(this, Unit.cm) } /** @@ -89,7 +89,7 @@ val Int.cm: CssSize */ val Int.mm: CssSize get() { - return Pair(this, UNIT.mm) + return Pair(this, Unit.mm) } /** @@ -98,7 +98,7 @@ val Int.mm: CssSize @Suppress("FunctionNaming") val Int.`in`: CssSize get() { - return Pair(this, UNIT.`in`) + return Pair(this, Unit.`in`) } /** @@ -106,7 +106,7 @@ val Int.`in`: CssSize */ val Int.pc: CssSize get() { - return Pair(this, UNIT.pc) + return Pair(this, Unit.pc) } /** @@ -114,7 +114,7 @@ val Int.pc: CssSize */ val Int.vh: CssSize get() { - return Pair(this, UNIT.vh) + return Pair(this, Unit.vh) } /** @@ -122,7 +122,7 @@ val Int.vh: CssSize */ val Int.vw: CssSize get() { - return Pair(this, UNIT.vw) + return Pair(this, Unit.vw) } /** @@ -130,7 +130,7 @@ val Int.vw: CssSize */ val Int.vmin: CssSize get() { - return Pair(this, UNIT.vmin) + return Pair(this, Unit.vmin) } /** @@ -138,19 +138,19 @@ val Int.vmin: CssSize */ val Int.vmax: CssSize get() { - return Pair(this, UNIT.vmax) + return Pair(this, Unit.vmax) } /** * Helper property to describe CSS auto value. */ -val auto: CssSize = Pair(0, UNIT.auto) +val auto: CssSize = Pair(0, Unit.auto) /** * Extension function to convert CssSize to String. */ fun CssSize.asString(): String { - return if (this.second != UNIT.auto) { + return if (this.second != Unit.auto) { this.first.toString() + this.second.unit } else { "auto" |