aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt23
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/KVManager.kt (renamed from src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt)51
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Component.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Css.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt1
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Types.kt9
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Widget.kt18
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt23
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt (renamed from src/main/kotlin/pl/treksoft/kvision/HMR.kt)7
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Image.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/List.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt4
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/modal/CloseIcon.kt (renamed from src/main/kotlin/pl/treksoft/kvision/helpers/CloseIcon.kt)8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt9
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/Root.kt (renamed from src/main/kotlin/pl/treksoft/kvision/core/Root.kt)6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/routing/Routing.kt13
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt (renamed from src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt)7
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt2
44 files changed, 151 insertions, 140 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt b/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt
deleted file mode 100644
index 83ad69ca..00000000
--- a/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * @author Robert Jaros
- */
-package pl.treksoft.kvision
-
-/**
- * Base class for applications.
- *
- * Every application class should inherit from this abstract class.
-*/
-abstract class ApplicationBase {
-/**
- * Starting point for an application.
- * @param state Initial state between Hot Module Replacement (HMR).
-*/
-abstract fun start(state: Map<String, Any>)
-
-/**
- * Ending point for an application.
- * @return final state for Hot Module Replacement (HMR).
-*/
-abstract fun dispose(): Map<String, Any>
-}
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt
index 7ca0ce26..5d5c03fa 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt
@@ -1,4 +1,7 @@
-package pl.treksoft.kvision.core
+/**
+ * @author Robert Jaros
+ */
+package pl.treksoft.kvision
import com.github.snabbdom.Snabbdom
import com.github.snabbdom.VNode
@@ -8,15 +11,19 @@ import com.github.snabbdom.datasetModule
import com.github.snabbdom.eventListenersModule
import com.github.snabbdom.propsModule
import com.github.snabbdom.styleModule
-import pl.treksoft.kvision.require
-import pl.treksoft.kvision.routing.Routing
-import pl.treksoft.kvision.routing.routing
import kotlin.browser.document
import kotlin.dom.clear
-external val kvBootstrap: Boolean?
+/**
+ * @suppress
+ * External function for loading CommonJS modules.
+ */
+external fun require(name: String): dynamic
-object KVManager {
+/**
+ * Internal singleton object which initializes and configures KVision framework.
+ */
+internal object KVManager {
internal const val AJAX_REQUEST_DELAY = 300
internal const val KVNULL = "#kvnull"
@@ -29,19 +36,26 @@ object KVManager {
private val fontAwesomeWebpack = require("font-awesome-webpack")
private val resizable = require("jquery-resizable-dom")
private val awesomeBootstrapCheckbox = require("awesome-bootstrap-checkbox")
- private val bootstrapSelectCss = require("bootstrap-select/dist/css/bootstrap-select.min.css")
+ private val bootstrapSelectCss =
+ require("bootstrap-select/dist/css/bootstrap-select.min.css")
private val bootstrapSelect = require("bootstrap-select")
private val bootstrapSelectI18n = require("./js/bootstrap-select-i18n.min.js")
- private val bootstrapSelectAjaxCss = require("ajax-bootstrap-select/dist/css/ajax-bootstrap-select.min.css")
- private val bootstrapSelectAjax = require("ajax-bootstrap-select/dist/js/ajax-bootstrap-select.min.js")
+ private val bootstrapSelectAjaxCss =
+ require("ajax-bootstrap-select/dist/css/ajax-bootstrap-select.min.css")
+ private val bootstrapSelectAjax =
+ require("ajax-bootstrap-select/dist/js/ajax-bootstrap-select.min.js")
// private val bootstrapSelectAjaxI18n =
// require("ajax-bootstrap-select/dist/js/locale/ajax-bootstrap-select.pl-PL.min.js")
private val trixCss = require("trix/dist/trix.css")
private val trix = require("trix")
- private val bootstrapDateTimePickerCss = require("bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css")
- private val bootstrapDateTimePicker = require("bootstrap-datetime-picker/js/bootstrap-datetimepicker.min.js")
- private val bootstrapTouchspinCss = require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.css")
- private val bootstrapTouchspin = require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js")
+ private val bootstrapDateTimePickerCss =
+ require("bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css")
+ private val bootstrapDateTimePicker =
+ require("bootstrap-datetime-picker/js/bootstrap-datetimepicker.min.js")
+ private val bootstrapTouchspinCss =
+ require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.css")
+ private val bootstrapTouchspin =
+ require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js")
internal val fecha = require("fecha")
private val sdPatch = Snabbdom.init(
@@ -67,15 +81,4 @@ object KVManager {
internal fun virtualize(html: String): VNode {
return sdVirtualize(html)
}
-
- fun init() {
- }
-
- fun start() {
- routing = Routing()
- }
-
- fun shutdown() {
- routing.destroy()
- }
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Component.kt b/src/main/kotlin/pl/treksoft/kvision/core/Component.kt
index bdd254ba..c322892c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Component.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Component.kt
@@ -3,8 +3,8 @@ package pl.treksoft.kvision.core
import com.github.snabbdom.VNode
import org.w3c.dom.Node
import pl.treksoft.jquery.JQuery
+import pl.treksoft.kvision.panel.Root
-@Suppress("TooManyFunctions")
interface Component {
var parent: Component?
var visible: Boolean
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt
index a5a85531..80860647 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt
@@ -3,8 +3,6 @@ package pl.treksoft.kvision.core
import pl.treksoft.kvision.utils.asString
import pl.treksoft.kvision.utils.toHexString
-typealias ResString = String
-
@Suppress("EnumNaming", "EnumEntryName")
enum class UNIT(val unit: String) {
px("px"),
@@ -24,8 +22,6 @@ enum class UNIT(val unit: String) {
auto("auto")
}
-typealias CssSize = Pair<Int, UNIT>
-
enum class BORDERSTYLE(val borderStyle: String) {
NONE("none"),
HIDDEN("hidden"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt
index b2676929..ed6def5f 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt
@@ -1,6 +1,5 @@
package pl.treksoft.kvision.core
-import pl.treksoft.kvision.snabbdom.StringPair
import pl.treksoft.kvision.utils.asString
abstract class StyledComponent : Component {
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Types.kt b/src/main/kotlin/pl/treksoft/kvision/core/Types.kt
new file mode 100644
index 00000000..05a4bec7
--- /dev/null
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Types.kt
@@ -0,0 +1,9 @@
+package pl.treksoft.kvision.core
+
+typealias ResString = String
+
+typealias StringPair = Pair<String, String>
+
+typealias StringBoolPair = Pair<String, Boolean>
+
+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 4ff7a640..08e67da0 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
@@ -7,15 +7,15 @@ import org.w3c.dom.CustomEventInit
import org.w3c.dom.Node
import pl.treksoft.jquery.JQuery
import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-import pl.treksoft.kvision.snabbdom.hooks
-import pl.treksoft.kvision.snabbdom.on
-import pl.treksoft.kvision.snabbdom.snAttrs
-import pl.treksoft.kvision.snabbdom.snClasses
-import pl.treksoft.kvision.snabbdom.snOpt
-import pl.treksoft.kvision.snabbdom.snStyle
+import pl.treksoft.kvision.KVManager
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.utils.hooks
+import pl.treksoft.kvision.utils.on
+import pl.treksoft.kvision.utils.snAttrs
+import pl.treksoft.kvision.utils.snClasses
+import pl.treksoft.kvision.utils.snOpt
+import pl.treksoft.kvision.utils.snStyle
@Suppress("TooManyFunctions", "LargeClass")
open class Widget(classes: Set<String> = setOf()) : StyledComponent() {
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 587b89cd..2e32ff7c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -11,9 +11,9 @@ import pl.treksoft.kvision.html.ListTag
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.obj
enum class DD(val type: String) {
HEADER("DD#HEADER"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt
index a28245d6..81275070 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt
@@ -2,7 +2,7 @@ package pl.treksoft.kvision.form
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
open class FieldLabel(
internal val forId: String, text: String? = null, rich: Boolean = false,
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
index 6c98244d..4ab94df5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
@@ -6,7 +6,7 @@ import pl.treksoft.kvision.form.check.Radio
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.core.StringBoolPair
import kotlin.js.Json
enum class FORMTYPE(val formType: String) {
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 6776b8eb..ea41c429 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
@@ -6,8 +6,8 @@ import pl.treksoft.kvision.form.BoolFormControl
import pl.treksoft.kvision.form.FieldLabel
import pl.treksoft.kvision.form.HelpBlock
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.core.StringBoolPair
enum class CHECKBOXSTYLE(val className: String) {
DEFAULT("checkbox-default"),
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 7114b2c2..a7d562a2 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
@@ -4,8 +4,8 @@ import com.github.snabbdom.VNode
import org.w3c.dom.events.MouseEvent
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.INPUTSIZE
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
enum class CHECKINPUTTYPE(val type: String) {
CHECKBOX("checkbox"),
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 d7fa502f..ac6df5b1 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
@@ -6,8 +6,8 @@ import pl.treksoft.kvision.form.BoolFormControl
import pl.treksoft.kvision.form.FieldLabel
import pl.treksoft.kvision.form.HelpBlock
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.core.StringBoolPair
enum class RADIOSTYLE(val className: String) {
DEFAULT("radio-default"),
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 fdf0e6a9..5060b6cb 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
@@ -7,8 +7,8 @@ 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
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
open class RadioGroup(
options: List<StringPair>? = null, value: String? = null, inline: Boolean = false,
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 9ba13f84..774bb654 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt
@@ -1,9 +1,9 @@
package pl.treksoft.kvision.form.select
import pl.treksoft.jquery.JQueryXHR
-import pl.treksoft.kvision.core.KVManager.AJAX_REQUEST_DELAY
-import pl.treksoft.kvision.core.KVManager.KVNULL
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.KVManager.AJAX_REQUEST_DELAY
+import pl.treksoft.kvision.KVManager.KVNULL
+import pl.treksoft.kvision.utils.obj
enum class HttpType(val type: String) {
GET("GET"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
index 5f10191f..49259ab1 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
@@ -6,9 +6,9 @@ import pl.treksoft.kvision.form.FieldLabel
import pl.treksoft.kvision.form.HelpBlock
import pl.treksoft.kvision.form.StringFormControl
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
@Suppress("TooManyFunctions")
open class Select(
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
index 6830823d..83eca138 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
@@ -3,13 +3,13 @@ package pl.treksoft.kvision.form.select
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Component
import pl.treksoft.kvision.core.CssSize
-import pl.treksoft.kvision.core.KVManager.KVNULL
+import pl.treksoft.kvision.KVManager.KVNULL
import pl.treksoft.kvision.form.INPUTSIZE
import pl.treksoft.kvision.html.BUTTONSTYLE
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.obj
import pl.treksoft.kvision.utils.asString
enum class SELECTWIDTHTYPE(val value: String) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt
index cfd2be19..391ee6a3 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt
@@ -2,7 +2,7 @@ package pl.treksoft.kvision.form.select
import com.github.snabbdom.VNode
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
open class SelectOptGroup(
label: String, options: List<StringPair>? = null, maxOptions: Int? = null,
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt
index 020d8f4b..f5ea25cd 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt
@@ -2,7 +2,7 @@ package pl.treksoft.kvision.form.select
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
open class SelectOption(
value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
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 5e2c460b..c6b49684 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
@@ -5,8 +5,8 @@ import pl.treksoft.kvision.form.FieldLabel
import pl.treksoft.kvision.form.HelpBlock
import pl.treksoft.kvision.form.NumberFormControl
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.core.StringBoolPair
open class Spinner(
value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP,
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 139a8ba9..ae064cdb 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
@@ -4,9 +4,9 @@ import com.github.snabbdom.VNode
import pl.treksoft.jquery.JQuery
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.INPUTSIZE
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.obj
enum class BUTTONSTYPE {
NONE,
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt
index 48b8d201..a3c89514 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt
@@ -5,8 +5,8 @@ import pl.treksoft.kvision.form.FieldLabel
import pl.treksoft.kvision.form.HelpBlock
import pl.treksoft.kvision.form.StringFormControl
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.core.StringBoolPair
abstract class AbstractText(label: String? = null, rich: Boolean = false) :
SimplePanel(setOf("form-group")), StringFormControl {
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 85cf6cf7..95a5d98b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt
@@ -3,8 +3,8 @@ package pl.treksoft.kvision.form.text
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.INPUTSIZE
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
abstract class AbstractTextInput(
value: String? = null,
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
index c96bc371..9df58266 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
@@ -2,7 +2,7 @@ package pl.treksoft.kvision.form.text
import com.github.snabbdom.VNode
import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
import kotlin.browser.document
open class RichTextInput(value: String? = null, classes: Set<String> = setOf()) :
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
index 01b531fb..8efe0318 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
@@ -1,7 +1,7 @@
package pl.treksoft.kvision.form.text
import com.github.snabbdom.VNode
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? = null, classes: Set<String> = setOf()) :
AbstractTextInput(value, classes + "form-control") {
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 d735c82e..bd945590 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
@@ -1,7 +1,7 @@
package pl.treksoft.kvision.form.text
import com.github.snabbdom.VNode
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
enum class TEXTINPUTTYPE(val type: String) {
TEXT("text"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
index db9fdeb1..1750c1bd 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
@@ -5,8 +5,8 @@ import pl.treksoft.kvision.form.DateFormControl
import pl.treksoft.kvision.form.FieldLabel
import pl.treksoft.kvision.form.HelpBlock
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.SnOn
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.utils.SnOn
+import pl.treksoft.kvision.core.StringBoolPair
import kotlin.js.Date
open class DateTime(
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
index a7aa758b..cac9fbda 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
@@ -3,9 +3,9 @@ package pl.treksoft.kvision.form.time
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.INPUTSIZE
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.obj
import pl.treksoft.kvision.utils.toDateF
import pl.treksoft.kvision.utils.toStringF
import kotlin.js.Date
diff --git a/src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt b/src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt
new file mode 100644
index 00000000..ceea0fbc
--- /dev/null
+++ b/src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt
@@ -0,0 +1,23 @@
+/**
+ * @author Robert Jaros
+ */
+package pl.treksoft.kvision.hmr
+
+/**
+ * Base class for applications.
+ *
+ * Base class for applications supporting Hot Module Replacement (HMR).
+ */
+abstract class ApplicationBase {
+ /**
+ * Starting point for an application.
+ * @param state Initial state between Hot Module Replacement (HMR).
+ */
+ abstract fun start(state: Map<String, Any>)
+
+ /**
+ * Ending point for an application.
+ * @return final state for Hot Module Replacement (HMR).
+ */
+ abstract fun dispose(): Map<String, Any>
+}
diff --git a/src/main/kotlin/pl/treksoft/kvision/HMR.kt b/src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt
index 6fb9dfed..59b6fe00 100644
--- a/src/main/kotlin/pl/treksoft/kvision/HMR.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt
@@ -1,7 +1,7 @@
/**
* @author Robert Jaros
*/
-package pl.treksoft.kvision
+package pl.treksoft.kvision.hmr
/**
* Helper variable for Hot Module Replacement (HMR).
@@ -27,8 +27,3 @@ external interface Hot {
fun dispose(callback: (data: dynamic) -> Unit)
}
-
-/**
- * External function for loading CommonJS modules.
- */
-external fun require(name: String): dynamic
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
index 4e8f7b3e..bb48558f 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
@@ -4,8 +4,8 @@ import com.github.snabbdom.VNode
import org.w3c.dom.events.MouseEvent
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
enum class BUTTONSTYLE(val className: String) {
DEFAULT("btn-default"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
index 913735ef..38b8825a 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
@@ -3,8 +3,8 @@ package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
enum class IMAGESHAPE(val className: String) {
ROUNDED("img-rounded"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index c61e8a79..83f03676 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -3,7 +3,7 @@ package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
open class Link(
label: String, url: String, icon: String? = null, image: ResString? = null,
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
index eb006a33..c4aed749 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
@@ -2,9 +2,9 @@ package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
import com.github.snabbdom.h
-import pl.treksoft.kvision.core.KVManager
+import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.core.StringBoolPair
enum class LIST(val tagName: String) {
UL("ul"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index d94505a8..11c935b2 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -1,9 +1,9 @@
package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
-import pl.treksoft.kvision.core.KVManager
+import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.core.StringBoolPair
@Suppress("EnumNaming")
enum class TAG(val tagName: String) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/helpers/CloseIcon.kt b/src/main/kotlin/pl/treksoft/kvision/modal/CloseIcon.kt
index b5f1a642..8751b03c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/helpers/CloseIcon.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/modal/CloseIcon.kt
@@ -1,10 +1,10 @@
-package pl.treksoft.kvision.helpers
+package pl.treksoft.kvision.modal
import com.github.snabbdom.VNode
-import pl.treksoft.kvision.core.KVManager
+import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
open class CloseIcon(classes: Set<String> = setOf()) : Widget(classes) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt
index 2c83077a..b5c985b7 100644
--- a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt
@@ -2,16 +2,15 @@ package pl.treksoft.kvision.modal
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Component
-import pl.treksoft.kvision.core.Root
import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.helpers.CloseIcon
import pl.treksoft.kvision.html.Button
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
+import pl.treksoft.kvision.panel.Root
import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.obj
enum class MODALSIZE(val className: String) {
LARGE("modal-lg"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt
index 66f2d422..ad3522ea 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt
@@ -3,7 +3,7 @@ package pl.treksoft.kvision.panel
import pl.treksoft.kvision.core.Component
import pl.treksoft.kvision.core.StyledComponent
import pl.treksoft.kvision.core.WidgetWrapper
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
import pl.treksoft.kvision.utils.px
enum class FLEXDIR(val dir: String) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt
index 3b226102..549f7631 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt
@@ -2,7 +2,7 @@ package pl.treksoft.kvision.panel
import pl.treksoft.kvision.core.Component
import pl.treksoft.kvision.core.WidgetWrapper
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
enum class GRIDJUSTIFY(val justify: String) {
START("start"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Root.kt b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
index 9d968874..88634bea 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Root.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
@@ -1,9 +1,9 @@
-package pl.treksoft.kvision.core
+package pl.treksoft.kvision.panel
import com.github.snabbdom.VNode
+import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.modal.Modal
-import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.snabbdom.StringBoolPair
+import pl.treksoft.kvision.core.StringBoolPair
class Root(id: String, private val fixed: Boolean = false) : SimplePanel() {
private val modals: MutableList<Modal> = mutableListOf()
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt
index 722f60e6..10595a37 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt
@@ -7,7 +7,7 @@ import pl.treksoft.kvision.core.StyledComponent
import pl.treksoft.kvision.core.UNIT
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.utils.obj
enum class DIRECTION(val dir: String) {
HORIZONTAL("horizontal"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/routing/Routing.kt b/src/main/kotlin/pl/treksoft/kvision/routing/Routing.kt
index fab8643c..4c9aa98d 100644
--- a/src/main/kotlin/pl/treksoft/kvision/routing/Routing.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/routing/Routing.kt
@@ -2,6 +2,17 @@ package pl.treksoft.kvision.routing
import pl.treksoft.navigo.Navigo
-open class Routing : Navigo(null, true, "#!")
+open class Routing : Navigo(null, true, "#!") {
+
+ companion object {
+ fun start() {
+ routing = Routing()
+ }
+
+ fun shutdown() {
+ routing.destroy()
+ }
+ }
+}
var routing = Routing()
diff --git a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt
index 0367633c..269fa6cb 100644
--- a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt
@@ -1,4 +1,4 @@
-package pl.treksoft.kvision.snabbdom
+package pl.treksoft.kvision.utils
import com.github.snabbdom.Attrs
import com.github.snabbdom.Classes
@@ -10,6 +10,8 @@ import com.github.snabbdom.VNodeStyle
import org.w3c.dom.CustomEvent
import org.w3c.dom.CustomEventInit
import pl.treksoft.jquery.JQueryEventObject
+import pl.treksoft.kvision.core.StringBoolPair
+import pl.treksoft.kvision.core.StringPair
import pl.treksoft.kvision.core.Widget
external class Object
@@ -75,9 +77,6 @@ internal fun hooks(): Hooks {
return js("({})")
}
-typealias StringPair = Pair<String, String>
-typealias StringBoolPair = Pair<String, Boolean>
-
@Suppress("UnsafeCastFromDynamic")
fun snStyle(pairs: List<StringPair>): VNodeStyle {
return obj {
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
index 80a7c482..7ba01135 100644
--- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
@@ -2,8 +2,8 @@
package pl.treksoft.kvision.utils
+import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.core.CssSize
-import pl.treksoft.kvision.core.KVManager
import pl.treksoft.kvision.core.UNIT
import kotlin.js.Date