Migration from 4.x to 5.x
This is the list of incompatibilities you may encounter when migrating your application to KVision 5.0.0.
General changes
All
classes: Set<String>constructor parameters and DSL builder parameters for all KVision components have been replaced withclassName: String?parameters (previously available only for DSL builders), taking a space-separated list of CSS class names.
// KVision 4
div(classes = setOf("card", "important")) {
+ "Some content"
}
// KVision 5
div(className = "card important") {
+ "Some content"
} All DSL builder functions with
ObservableStateparameter have been removed. Usebind()extension function instead (from the newkvision-statemodule).
val state = ObservableValue("Centered content")
// KVision 4
div(state, align = Align.CENTER) {
p(it)
}
// KVision 5
div(align = Align.CENTER).bind(state) {
p(it)
}FlexPanel,HPanel,VPanelandGridPanelcontainers don't render wrapper DIVs by default for their children components. The previously availablenoWrappersparameter has been removed and newuseWrappers(defaults tofalse) parameter has been introduced (note the opposite meaning!). To make migrations easier, a compatibility parameterpanelsCompatibilityModeis available withinstartApplication()function. When set totrue, theuseWrappersdefault value will betrue, and you will only need to replacenoWrappers = truewithuseWrappers = falseto migrate your whole app.
The default values for
Rootcontainer parameters have been changed. Previouslycontainer-fluidwas the default CSS class applied and additional element withrowclass was also generated. In KVision 5Rootcontainer by default doesn't render any additional markup.
Bootstrap 5 introduces many breaking changes. You should definitely read Bootstrap's migration guide if you use Bootstrap CSS classes directly.
Micronaut 3.0 introduces some breaking changes. Check out Micronaut upgrading guide.
Javalin 4.0 introduces some breaking changes. Check out the changelog.
Modules
All modules which include CSS stylesheets require explicit initialization. This also applies to the core module. This initialization ensures a predictable order in which all styles will be applied. The initialization is performed by adding dedicated module objects as parameters to the
startApplication()function.
These methods:
getElementJQuery(),getElementJQueryD(),showAnim(),hideAnim(),slideDown(),slideUp(),fadeIn(),fadeOut()andanimate()of theWidgetclass have been extracted to the newkvision-jquerymodule as the extension functions.Other jQuery dependencies (including static
jQuery()function) have been moved to thekvision-jquerymodule as well. The core module no longer depends on jQuery library.The
RestClientcomponent has been moved to the newkvision-restmodule and completely redesigned (including its API). To make migrations easier, the original, jQuery based client has been moved to thekvision-jquerymodule as a deprecatedLegacyRestClient.The
ObservableListandObservableSetclasses and data bindings functionsbind(),bindEach()andbindTo()have been moved to thekvision-statemodule.The
Tablecomponent has been moved to thekvision-bootstrapmodule.The
kvision-event-flowmodule has been renamed tokvision-state-flow.
Events
KVision no longer re-dispatches native component events as custom events. Instead it gives you the possibility to add direct listeners for all events with event() and jqueryEvent() extension functions, used inside onEvent function.
Standard events
For standard events, just use the name.
KVision custom events
For custom KVision events (defined by SplitPanel, Window, Tabulator, TabPanel and some OnsenUI components) use the name of the event as well. Note: events for Tabulator and TabPanel component have been renamed (e.g. tabulatorRowClick -> rowClickTabulator).
Bootstrap custom events
For events defined by Bootstrap components, which cannot be used like above because of their names, use event() extension function.
jQuery events
For events defined by jQuery based components (Select, Spinner, DateTime, Typeahead, Upload) use jqueryEvent() extension function.
Other changes
The
SplitPanelcontainer is now sized with percentage values. You can useminWidthand/ormaxWidthproperties for the child component to block automatic resizing.Due to Bootstrap 5 limitation, components can't have both tooltip and popover enabled at the same time.
Tabulatorcomponent no longer uses table types enums of theTablecomponent. It now has its own enum values in its ownkvision-tabulatormodule.Styleobjects have been refactored. The order of constructor parameters has changed. TheclassNameparameter has been renamed toselectorto avoid confusion.The KVision Gradle plugin ID has changed from
kvisiontoio.kvisionand maven coordinates of the plugin artifacts have changed to comply with Gradle conventions. TheresolutionStrategyblock insettings.gradle.ktsfile is no longer required for KVision plugin. The plugin is now used with frontend-only projects as well, to simplify build file configuration.