aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-bootstrap/src/main/resources/css/style.css47
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt12
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt2
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt2
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt2
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt4
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt2
-rw-r--r--kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartCanvasSpec.kt4
-rw-r--r--kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartSpec.kt4
-rw-r--r--kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt2
-rw-r--r--kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt4
-rw-r--r--kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt2
-rw-r--r--kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt2
-rw-r--r--kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt4
-rw-r--r--kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt2
-rw-r--r--kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt2
-rw-r--r--kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt4
-rw-r--r--kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt10
-rw-r--r--kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt2
-rw-r--r--kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt2
-rw-r--r--kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt2
-rw-r--r--kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt2
-rw-r--r--kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt4
-rw-r--r--kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt6
-rw-r--r--kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt6
-rw-r--r--kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt139
-rw-r--r--kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt18
-rw-r--r--kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/tabulator/TabulatorSpec.kt2
-rw-r--r--kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt4
-rw-r--r--kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt2
-rw-r--r--kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt2
41 files changed, 243 insertions, 79 deletions
diff --git a/kvision-modules/kvision-bootstrap/src/main/resources/css/style.css b/kvision-modules/kvision-bootstrap/src/main/resources/css/style.css
index a0314ced..992a5a0b 100644
--- a/kvision-modules/kvision-bootstrap/src/main/resources/css/style.css
+++ b/kvision-modules/kvision-bootstrap/src/main/resources/css/style.css
@@ -163,3 +163,50 @@ ul.tabs-top > li {
float:none;
flex-shrink: 0;
}
+
+.kv-tab-close {
+ margin-left: 10px;
+ color: #000;
+ text-shadow: 0 1px 0 #fff;
+ filter: alpha(opacity=20);
+ opacity: 0.2;
+}
+
+.kv-tab-close:hover, .kv-tab-close:focus {
+ cursor: pointer;
+ filter: alpha(opacity=50);
+ opacity: 0.5;
+}
+
+select.form-control, .tabulator-row .tabulator-cell.tabulator-editing select {
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ background: transparent none no-repeat;
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAKCAYAAABblxXYAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wUKFyIn4IjqJgAAAENJREFUKM/l0LERACEQQlGsiTa2px1aokGugNNAx8wfMy8AeLoBALYjaTqoKkga2+gKPgF/2Q7JkEx359oftu+C7/UBCUIcVQz0PvcAAAAASUVORK5CYII=');
+ background-position: right center;
+ cursor: pointer;
+}
+
+select.form-control:hover {
+ background-color: #e6e6e6;
+}
+
+select.form-control option {
+ background-color: white;
+}
+
+select.input-sm {
+ line-height: inherit;
+}
+
+.tabulator-row .tabulator-cell.tabulator-editing input, .tabulator-row .tabulator-cell.tabulator-editing select {
+ border: 1px solid #ccc;
+ border-radius: 4px;
+}
+
+.tabulator-row .tabulator-cell.tabulator-editing input:focus, .tabulator-row .tabulator-cell.tabulator-editing select:focus {
+ border-color: #66afe9;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 2fc0320a..1ad97acc 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -88,7 +88,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
index ff4daea7..af35fa51 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -34,7 +34,7 @@ class DropDownSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag")
root.add(dd)
dd.toggle()
@@ -51,7 +51,7 @@ class DropDownSpec : DomSpec {
@Test
fun renderDropUp() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag").apply { dropup = true }
root.add(dd)
dd.toggle()
@@ -68,7 +68,7 @@ class DropDownSpec : DomSpec {
@Test
fun renderHeaderElement() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.option), "flag")
root.add(dd)
dd.toggle()
@@ -85,7 +85,7 @@ class DropDownSpec : DomSpec {
@Test
fun renderSeparatorElement() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to DD.SEPARATOR.option), "flag")
root.add(dd)
dd.toggle()
@@ -102,7 +102,7 @@ class DropDownSpec : DomSpec {
@Test
fun renderDisabledElement() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to DD.DISABLED.option), "flag")
root.add(dd)
dd.toggle()
@@ -119,7 +119,7 @@ class DropDownSpec : DomSpec {
@Test
fun toggle() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag")
root.add(dd)
val visible = dd.getElementJQuery()?.hasClass("open") ?: false
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt
index 807f837a..c3d17de9 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt
@@ -36,7 +36,7 @@ class AlertSpec : DomSpec {
@Test
fun render() {
run {
- Root("test", true)
+ Root("test", fixed = true)
Alert.show("Alert caption", "Alert content")
val alert = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] }
assertNotNull(alert, "Should show alert window")
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt
index 2e3ea3ef..1893ce81 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt
@@ -32,7 +32,7 @@ class CloseIconSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val ci = CloseIcon()
root.add(ci)
val element = document.getElementById("test")
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt
index dc734e10..875bf9e2 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt
@@ -36,7 +36,7 @@ class ConfirmSpec : DomSpec {
@Test
fun render() {
run {
- Root("test", true)
+ Root("test", fixed = true)
Confirm.show("Confirm caption", "Confirm content")
val confirm = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] }
assertNotNull(confirm, "Should show confirm window")
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt
index 523abfd5..7149b163 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt
@@ -35,7 +35,7 @@ class ModalSpec : DomSpec {
@Test
fun render() {
run {
- Root("test", true)
+ Root("test", fixed = true)
val modal = Modal("Modal")
modal.show()
val content = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() }
@@ -47,7 +47,7 @@ class ModalSpec : DomSpec {
@Test
fun toggle() {
run {
- Root("test", true)
+ Root("test", fixed = true)
val modal = Modal("Modal")
modal.toggle()
val content = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() }
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt
index e87626ca..c79b9d32 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt
@@ -32,7 +32,7 @@ class WindowSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val window = Window("Window title", isResizable = false)
root.add(window)
val id = window.id
diff --git a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartCanvasSpec.kt b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartCanvasSpec.kt
index 6fae54ad..da83b989 100644
--- a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartCanvasSpec.kt
+++ b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartCanvasSpec.kt
@@ -36,7 +36,7 @@ class ChartCanvasSpec : DomSpec {
@Test
fun renderResponsive() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val chart = ChartCanvas(
configuration = Configuration(
ChartType.SCATTER,
@@ -56,7 +56,7 @@ class ChartCanvasSpec : DomSpec {
@Test
fun renderNotResponsive() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val chart = ChartCanvas(
300, 600,
configuration = Configuration(
diff --git a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartSpec.kt b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartSpec.kt
index 7974ea78..1fe73608 100644
--- a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartSpec.kt
+++ b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/chart/ChartSpec.kt
@@ -37,7 +37,7 @@ class ChartSpec : DomSpec {
@Test
fun renderResponsive() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val chart = Chart(
Configuration(
ChartType.SCATTER,
@@ -60,7 +60,7 @@ class ChartSpec : DomSpec {
@Test
fun renderNotResponsive() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val chart = Chart(
Configuration(
ChartType.SCATTER,
diff --git a/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt b/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt
index 931294d5..556d3991 100644
--- a/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt
+++ b/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt
@@ -36,7 +36,7 @@ class DataContainerSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
class Model(value: String) : BaseDataComponent() {
var value: String by obs(value)
diff --git a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
index 7c1c8d71..5858d04b 100644
--- a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
+++ b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
@@ -282,14 +282,14 @@ open class DateTimeInput(
/**
* Makes the input element focused.
*/
- open fun focus() {
+ override fun focus() {
getElementJQuery()?.focus()
}
/**
* Makes the input element blur.
*/
- open fun blur() {
+ override fun blur() {
getElementJQuery()?.blur()
}
diff --git a/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt b/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt
index 69ab46ec..877cf650 100644
--- a/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt
+++ b/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt
@@ -34,7 +34,7 @@ class DateTimeInputSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val data = Date()
val dti = DateTimeInput(value = data).apply {
placeholder = "place"
diff --git a/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt b/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt
index 19cefd86..b5e393bb 100644
--- a/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt
+++ b/kvision-modules/kvision-datetime/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt
@@ -34,7 +34,7 @@ class DateTimeSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val data = Date()
val ti = DateTime(value = data, label = "Label").apply {
placeholder = "place"
diff --git a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt
index 0271a956..5204402d 100644
--- a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt
+++ b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt
@@ -55,7 +55,7 @@ class StateBindingSpec : DomSpec {
@Test
fun stateBinding() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val store = createReduxStore(::stateReducer, State(10))
val container = SimplePanel()
@@ -81,7 +81,7 @@ class StateBindingSpec : DomSpec {
@Test
fun stateUpdate() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val store = createReduxStore(::stateReducer, State(10))
val container = SimplePanel()
diff --git a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt
index 21b7dc39..4ebf7b45 100644
--- a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt
+++ b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt
@@ -34,7 +34,7 @@ class RichTextInputSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val hai = RichTextInput(value = "abc").apply {
placeholder = "place"
id = "idti"
diff --git a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt
index 844b7e94..1ea79790 100644
--- a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt
+++ b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt
@@ -34,7 +34,7 @@ class RichTextSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val hai = RichText(value = "abc", label = "Field").apply {
placeholder = "place"
id = "idti"
diff --git a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
index f19081e1..db8a5b3b 100644
--- a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
+++ b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
@@ -39,7 +39,7 @@ import pl.treksoft.kvision.utils.SnOn
* [SelectOption] or [SelectOptGroup] components to the container.
*
* @constructor
- * @param options an optional list of options (label to value pairs) for the select control
+ * @param options an optional list of options (value to label pairs) for the select control
* @param value selected value
* @param name the name attribute of the generated HTML input element
* @param multiple allows multiple value selection (multiple values are comma delimited)
@@ -55,7 +55,7 @@ open class Select(
) : SimplePanel(setOf("form-group")), StringFormControl {
/**
- * A list of options (label to value pairs) for the select control.
+ * A list of options (value to label pairs) for the select control.
*/
var options
get() = input.options
diff --git a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
index 7ffdf2c2..9ae1a4e9 100644
--- a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
+++ b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
@@ -50,7 +50,7 @@ enum class SelectWidthType(internal val value: String) {
* [SelectOption] or [SelectOptGroup] components to the container.
*
* @constructor
- * @param options an optional list of options (label to value pairs) for the select control
+ * @param options an optional list of options (value to label pairs) for the select control
* @param value selected value
* @param multiple allows multiple value selection (multiple values are comma delimited)
* @param ajaxOptions additional options for remote (AJAX) data source
@@ -64,9 +64,9 @@ open class SelectInput(
) : SimplePanel(classes), FormInput {
/**
- * A list of options (label to value pairs) for the select control.
+ * A list of options (value to label pairs) for the select control.
*/
- internal var options by refreshOnUpdate(options) { setChildrenFromOptions() }
+ var options by refreshOnUpdate(options) { setChildrenFromOptions() }
/**
* A value of the selected option.
*/
@@ -337,14 +337,14 @@ open class SelectInput(
/**
* Makes the input element focused.
*/
- open fun focus() {
+ override fun focus() {
getElementJQuery()?.focus()
}
/**
* Makes the input element blur.
*/
- open fun blur() {
+ override fun blur() {
getElementJQuery()?.blur()
}
diff --git a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt
index 30f42e9c..bfd93900 100644
--- a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt
+++ b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt
@@ -34,7 +34,7 @@ class SelectInputSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val selectInput = SelectInput(listOf("test1" to "Test 1", "test2" to "Test 2"), "test1", true).apply {
liveSearch = true
placeholder = "Choose ..."
diff --git a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt
index bd88f560..33ccc843 100644
--- a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt
+++ b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt
@@ -33,7 +33,7 @@ class SelectOptGroupSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val selectOptGroup = SelectOptGroup("Group", listOf("test1" to "Test 1", "test2" to "Test 2"), 2)
root.add(selectOptGroup)
val element = document.getElementById("test")
diff --git a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt
index f7e07d42..33c36576 100644
--- a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt
+++ b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt
@@ -32,7 +32,7 @@ class SelectOptionSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val selectOption = SelectOption("testValue", "testLabel")
root.add(selectOption)
val element = document.getElementById("test")
diff --git a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt
index eaccd551..9eddff81 100644
--- a/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt
+++ b/kvision-modules/kvision-select/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt
@@ -34,7 +34,7 @@ class SelectSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val select = Select(listOf("test1" to "Test 1", "test2" to "Test 2"), "test1", null, true, null, "Label").apply {
liveSearch = true
placeholder = "Choose ..."
diff --git a/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
index c60aab2f..66e98ab5 100644
--- a/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
+++ b/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
@@ -293,14 +293,14 @@ open class SpinnerInput(
/**
* Makes the input element focused.
*/
- open fun focus() {
+ override fun focus() {
getElementJQuery()?.focus()
}
/**
* Makes the input element blur.
*/
- open fun blur() {
+ override fun blur() {
getElementJQuery()?.blur()
}
diff --git a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt
index a240bfd8..467e48db 100644
--- a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt
+++ b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt
@@ -32,7 +32,7 @@ class SpinnerInputSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val si = SpinnerInput(value = 13).apply {
placeholder = "place"
id = "idti"
@@ -46,7 +46,7 @@ class SpinnerInputSpec : DomSpec {
@Test
fun spinUp() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val si = SpinnerInput(value = 13).apply {
placeholder = "place"
id = "idti"
@@ -61,7 +61,7 @@ class SpinnerInputSpec : DomSpec {
@Test
fun spinDown() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val si = SpinnerInput(value = 13).apply {
placeholder = "place"
id = "idti"
diff --git a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt
index 30f12a93..928fe0b1 100644
--- a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt
+++ b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt
@@ -33,7 +33,7 @@ class SpinnerSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val ti = Spinner(value = 13, label = "Label").apply {
placeholder = "place"
name = "name"
@@ -59,7 +59,7 @@ class SpinnerSpec : DomSpec {
@Test
fun spinUp() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val si = Spinner(value = 13)
root.add(si)
assertEquals(13, si.value, "Should return initial value before spinUp")
@@ -71,7 +71,7 @@ class SpinnerSpec : DomSpec {
@Test
fun spinDown() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val si = Spinner(value = 13)
root.add(si)
assertEquals(13, si.value, "Should return initial value before spinDown")
diff --git a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt
index dac29ab9..dd3bff5f 100644
--- a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt
+++ b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt
@@ -22,8 +22,19 @@
package pl.treksoft.kvision.tabulator
+import kotlinx.serialization.KSerializer
+import org.w3c.dom.HTMLElement
+import pl.treksoft.kvision.core.Component
+import pl.treksoft.kvision.form.FormControl
+import pl.treksoft.kvision.form.FormInput
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.tabulator.EditorRoot.disposeTimer
+import pl.treksoft.kvision.tabulator.EditorRoot.root
import pl.treksoft.kvision.tabulator.js.Tabulator
+import pl.treksoft.kvision.utils.JSON
import pl.treksoft.kvision.utils.obj
+import kotlin.browser.document
+import kotlin.browser.window
import kotlin.js.Promise
/**
@@ -248,7 +259,7 @@ fun DownloadConfig.toJs(): Tabulator.DownloadConfig {
/**
* Column definition options.
*/
-data class ColumnDefinition(
+data class ColumnDefinition<T : Any>(
val title: String,
val field: String? = null,
val visible: Boolean? = null,
@@ -265,18 +276,36 @@ data class ColumnDefinition(
val rowHandle: Boolean? = null,
val hideInHtml: Boolean? = null,
val sorter: Sorter? = null,
+ val sorterFunction: ((
+ a: dynamic, b: dynamic, aRow: Tabulator.RowComponent, bRow: Tabulator.RowComponent,
+ column: Tabulator.ColumnComponent, dir: SortingDir, sorterParams: dynamic
+ ) -> Number)? = null,
val sorterParams: dynamic = null,
val formatter: Formatter? = null,
val formatterFunction: ((
cell: Tabulator.CellComponent, formatterParams: dynamic,
onRendered: (callback: () -> Unit) -> Unit
) -> dynamic)? = null,
+ val formatterComponentFunction: ((
+ cell: Tabulator.CellComponent, onRendered: (callback: () -> Unit) -> Unit, data: T
+ ) -> Component)? = null,
val formatterParams: dynamic = null,
val variableHeight: Boolean? = null,
val editable: ((cell: Tabulator.CellComponent) -> Boolean)? = null,
val editor: Editor? = null,
+ val editorFunction: ((
+ cell: Tabulator.CellComponent,
+ onRendered: (callback: () -> Unit) -> Unit,
+ success: (value: dynamic) -> Unit, cancel: (value: dynamic) -> Unit, editorParams: dynamic
+ ) -> dynamic)? = null,
+ val editorComponentFunction: ((
+ cell: Tabulator.CellComponent,
+ onRendered: (callback: () -> Unit) -> Unit,
+ success: (value: dynamic) -> Unit, cancel: (value: dynamic) -> Unit, data: T
+ ) -> Component)? = null,
val editorParams: dynamic = null,
val validator: Validator? = null,
+ val validatorFunction: dynamic = null,
val validatorParams: String? = null,
val download: Boolean? = null,
val downloadTitle: String? = null,
@@ -325,11 +354,78 @@ data class ColumnDefinition(
val cellEditCancelled: ((cell: Tabulator.CellComponent) -> Unit)? = null
)
+internal object EditorRoot {
+ internal var root: Root? = null
+ internal var disposeTimer: Int? = null
+}
+
/**
* An extension function to convert column definition class to JS object.
*/
-@Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE", "ComplexMethod")
-fun ColumnDefinition.toJs(i18nTranslator: (String) -> (String)): Tabulator.ColumnDefinition {
+@Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE", "ComplexMethod", "MagicNumber")
+fun <T : Any> ColumnDefinition<T>.toJs(
+ i18nTranslator: (String) -> (String),
+ dataSerializer: KSerializer<T>? = null
+): Tabulator.ColumnDefinition {
+ val tmpEditorFunction = editorComponentFunction?.let {
+ { cell: Tabulator.CellComponent,
+ onRendered: (callback: () -> Unit) -> Unit,
+ success: (value: dynamic) -> Unit, cancel: (value: dynamic) -> Unit, _: dynamic ->
+ var onRenderedCallback: (() -> Unit)? = null
+ val str = kotlin.js.JSON.stringify(cell.getData())
+ @Suppress("UNCHECKED_CAST") val data = dataSerializer?.let {
+ JSON.plain.parse(it, str)
+ } ?: cell.getData() as T
+ val component = it(cell, { callback ->
+ onRenderedCallback = callback
+ }, { value ->
+ success(value)
+ disposeTimer = window.setTimeout({
+ root?.dispose()
+ disposeTimer = null
+ root = null
+ }, 500)
+ }, cancel, data)
+ val rootElement = document.createElement("div") as HTMLElement
+ onRendered {
+ if (root != null) {
+ disposeTimer?.let { window.clearTimeout(it) }
+ root?.dispose()
+ }
+ root = Root(element = rootElement)
+ @Suppress("UnsafeCastFromDynamic")
+ root?.add(component)
+ (component as? FormControl)?.focus()
+ (component as? FormInput)?.focus()
+ cell.checkHeight()
+ onRenderedCallback?.invoke()
+ }
+ rootElement
+ }
+ }
+
+ val tmpFormatterFunction = formatterComponentFunction?.let {
+ { cell: Tabulator.CellComponent, _: dynamic,
+ onRendered: (callback: () -> Unit) -> Unit ->
+ var onRenderedCallback: (() -> Unit)? = null
+ val str = kotlin.js.JSON.stringify(cell.getData())
+ @Suppress("UNCHECKED_CAST") val data =
+ dataSerializer?.let { JSON.plain.parse(it, str) } ?: cell.getData() as T
+ val component = it(cell, { callback ->
+ onRenderedCallback = callback
+ }, data)
+ val rootElement = document.createElement("div") as HTMLElement
+ onRendered {
+ val root = Root(element = rootElement)
+ @Suppress("UnsafeCastFromDynamic")
+ root.add(component)
+ cell.checkHeight()
+ onRenderedCallback?.invoke()
+ }
+ rootElement
+ }
+ }
+
return obj {
this.title = i18nTranslator(title)
if (field != null) this.field = field
@@ -346,9 +442,15 @@ fun ColumnDefinition.toJs(i18nTranslator: (String) -> (String)): Tabulator.Colum
if (cssClass != null) this.cssClass = cssClass
if (rowHandle != null) this.rowHandle = rowHandle
if (hideInHtml != null) this.hideInHtml = hideInHtml
- if (sorter != null) this.sorter = sorter.sorter
+ if (sorterFunction != null) {
+ this.sorter = sorterFunction
+ } else if (sorter != null) {
+ this.sorter = sorter.sorter
+ }
if (sorterParams != null) this.sorterParams = sorterParams
- if (formatterFunction != null) {
+ if (tmpFormatterFunction != null) {
+ this.formatter = tmpFormatterFunction
+ } else if (formatterFunction != null) {
this.formatter = formatterFunction
} else if (formatter != null) {
this.formatter = formatter.formatter
@@ -356,7 +458,13 @@ fun ColumnDefinition.toJs(i18nTranslator: (String) -> (String)): Tabulator.Colum
if (formatterParams != null) this.formatterParams = formatterParams
if (variableHeight != null) this.variableHeight = variableHeight
if (editable != null) this.editable = editable
- if (editor != null) this.editor = editor.editor
+ if (tmpEditorFunction != null) {
+ this.editor = tmpEditorFunction
+ } else if (editorFunction != null) {
+ this.editor = editorFunction
+ } else if (editor != null) {
+ this.editor = editor.editor
+ }
if (editorParams != null) this.editorParams = editorParams
if (validator != null) this.validator = validator.validator
if (validatorParams != null) this.validatorParams = validatorParams
@@ -404,14 +512,20 @@ fun ColumnDefinition.toJs(i18nTranslator: (String) -> (String)): Tabulator.Colum
if (cellMouseMove != null) this.cellMouseMove = cellMouseMove
if (cellEditing != null) this.cellEditing = cellEditing
if (cellEdited != null) this.cellEdited = cellEdited
- if (cellEditCancelled != null) this.cellEditCancelled = cellEditCancelled
+ if (cellEditCancelled != null) {
+ this.cellEditCancelled = cellEditCancelled
+ } else if (tmpEditorFunction != null) {
+ this.cellEditCancelled = { cell: Tabulator.CellComponent ->
+ cell.checkHeight()
+ }
+ }
} as Tabulator.ColumnDefinition
}
/**
* Tabulator options.
*/
-data class TabulatorOptions(
+data class TabulatorOptions<T : Any>(
val height: String? = null,
val virtualDom: Boolean? = null,
val virtualDomBuffer: Int? = null,
@@ -425,7 +539,7 @@ data class TabulatorOptions(
val downloadConfig: DownloadConfig? = null,
val reactiveData: Boolean? = null,
val autoResize: Boolean? = null,
- val columns: List<ColumnDefinition>? = null,
+ val columns: List<ColumnDefinition<T>>? = null,
val autoColumns: Boolean? = null,
val layout: Layout? = null,
val layoutColumnsOnNewData: Boolean? = null,
@@ -572,7 +686,10 @@ data class TabulatorOptions(
* An extension function to convert tabulator options class to JS object.
*/
@Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE", "ComplexMethod")
-fun TabulatorOptions.toJs(i18nTranslator: (String) -> (String)): Tabulator.Options {
+fun <T : Any> TabulatorOptions<T>.toJs(
+ i18nTranslator: (String) -> (String),
+ dataSerializer: KSerializer<T>? = null
+): Tabulator.Options {
return obj {
if (height != null) this.height = height
if (virtualDom != null) this.virtualDom = virtualDom
@@ -587,7 +704,7 @@ fun TabulatorOptions.toJs(i18nTranslator: (String) -> (String)): Tabulator.Optio
if (downloadConfig != null) this.downloadConfig = downloadConfig.toJs()
if (reactiveData != null) this.reactiveData = reactiveData
if (autoResize != null) this.autoResize = autoResize
- if (columns != null) this.columns = columns.map { it.toJs(i18nTranslator) }.toTypedArray()
+ if (columns != null) this.columns = columns.map { it.toJs(i18nTranslator, dataSerializer) }.toTypedArray()
if (autoColumns != null) {
this.autoColumns = autoColumns
} else if (columns == null) {
diff --git a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt
index 249c578f..6c7480fc 100644
--- a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt
+++ b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt
@@ -54,7 +54,7 @@ import pl.treksoft.kvision.tabulator.js.Tabulator as JsTabulator
@Suppress("LargeClass", "TooManyFunctions")
open class Tabulator<T : Any>(
protected val data: List<T>? = null,
- val options: TabulatorOptions = TabulatorOptions(),
+ val options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
protected val dataSerializer: KSerializer<T>? = null
@@ -228,7 +228,7 @@ open class Tabulator<T : Any>(
(this.getElement() as? HTMLElement)?.let {
jsTabulator =
KVManagerTabulator.getConstructor()
- .createInstance(it, options.toJs(this::translate))
+ .createInstance(it, options.toJs(this::translate, dataSerializer))
if (currentPage != null) {
jsTabulator?.setPageSize(pageSize ?: 0)
jsTabulator?.setPage(currentPage)
@@ -561,7 +561,7 @@ open class Tabulator<T : Any>(
*/
inline fun <reified T : Any> Container.tabulator(
data: List<T>? = null,
- options: TabulatorOptions = TabulatorOptions(),
+ options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
noinline init: (Tabulator<T>.() -> Unit)? = null
@@ -578,7 +578,7 @@ open class Tabulator<T : Any>(
inline fun <reified T : Any, S : Any, A : RAction> Container.tabulator(
store: ReduxStore<S, A>,
noinline dataFactory: (S) -> List<T>,
- options: TabulatorOptions = TabulatorOptions(),
+ options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
noinline init: (Tabulator<T>.() -> Unit)? = null
@@ -594,7 +594,7 @@ open class Tabulator<T : Any>(
*/
inline fun <reified T : Any, A : RAction> Container.tabulator(
store: ReduxStore<List<T>, A>,
- options: TabulatorOptions = TabulatorOptions(),
+ options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
noinline init: (Tabulator<T>.() -> Unit)? = null
@@ -609,7 +609,7 @@ open class Tabulator<T : Any>(
* DSL builder extension function for dynamic data (send within options parameter).
*/
fun <T : Any> Container.tabulator(
- options: TabulatorOptions = TabulatorOptions(),
+ options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
init: (Tabulator<T>.() -> Unit)? = null
@@ -625,7 +625,7 @@ open class Tabulator<T : Any>(
*/
@UseExperimental(ImplicitReflectionSerializer::class)
inline fun <reified T : Any> create(
- data: List<T>? = null, options: TabulatorOptions = TabulatorOptions(),
+ data: List<T>? = null, options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
noinline init: (Tabulator<T>.() -> Unit)? = null
@@ -642,7 +642,7 @@ open class Tabulator<T : Any>(
inline fun <reified T : Any, S : Any, A : RAction> create(
store: ReduxStore<S, A>,
noinline dataFactory: (S) -> List<T>,
- options: TabulatorOptions = TabulatorOptions(),
+ options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
noinline init: (Tabulator<T>.() -> Unit)? = null
@@ -662,7 +662,7 @@ open class Tabulator<T : Any>(
@UseExperimental(ImplicitReflectionSerializer::class)
inline fun <reified T : Any, A : RAction> create(
store: ReduxStore<List<T>, A>,
- options: TabulatorOptions = TabulatorOptions(),
+ options: TabulatorOptions<T> = TabulatorOptions(),
types: Set<TableType> = setOf(),
classes: Set<String> = setOf(),
noinline init: (Tabulator<T>.() -> Unit)? = null
diff --git a/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/tabulator/TabulatorSpec.kt b/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/tabulator/TabulatorSpec.kt
index d6b33a78..1f49ee93 100644
--- a/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/tabulator/TabulatorSpec.kt
+++ b/kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/tabulator/TabulatorSpec.kt
@@ -34,7 +34,7 @@ class TabulatorSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val tabulator = Tabulator<Any>(options = TabulatorOptions(data = arrayOf(obj {
id = 1
name = "Name"
diff --git a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
index a250df42..39c4c4c6 100644
--- a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
+++ b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
@@ -278,14 +278,14 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla
/**
* Makes the input element focused.
*/
- open fun focus() {
+ override fun focus() {
getElementJQuery()?.focus()
}
/**
* Makes the input element blur.
*/
- open fun blur() {
+ override fun blur() {
getElementJQuery()?.blur()
}
diff --git a/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 37d7a9df..13c8531b 100644
--- a/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -86,7 +86,7 @@ interface WSpec : DomSpec {
fun runW(code: (widget: Widget, element: Element?) -> Unit) {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val widget = Widget()
widget.id = "test_id"
root.add(widget)
diff --git a/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt b/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt
index 626b70e4..de7a9315 100644
--- a/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt
+++ b/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt
@@ -33,7 +33,7 @@ class UploadInputSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val upi = UploadInput(multiple = true).apply {
id = "idti"
}
diff --git a/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt b/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt
index bea4ddee..92078153 100644
--- a/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt
+++ b/kvision-modules/kvision-upload/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt
@@ -33,7 +33,7 @@ class UploadSpec : DomSpec {
@Test
fun render() {
run {
- val root = Root("test", true)
+ val root = Root("test", fixed = true)
val upi = Upload(multiple = true)
val id = upi.input.id
root.add(upi)