diff options
53 files changed, 280 insertions, 277 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( |
