Developing Custom Plugins
Plugins are used to extend KASKO frontend with additional functionality. Most commonly they will be used to create custom components. For this WEB Components are used. Any frontend framework can be used to create custom components as long as they are correctly transformed to web components. Most frameworks (including Angular, React, Vue) have wrapper modules that allow this functionality out-of-the-box. Note that this will have impact on performance. Hence it is recommended to use native WEB Components or LitElement.
Creating plugins
Demo plugins in the most popular frameworks can be viewed in the kasko-demo-plugins repository.
Each plugin consists of the following attributes:
plugin name
plugin WEB component/s
plugin validators
Example Plugin
class MyCustomComponent extends HTMLElement {
constructTemplate() {
return '<p>Hello World</p>';
}
connectedCallback() {
this.innerHTML = this.constructTemplate();
}
}
window.registerKaskoPlugin('my-plugin', {
components: [
{
type: 'my-custom-component',
component: MyCustomComponent,
},
],
});Example Validation Plugin
NOTE: Validators CAN be defined without
componentsand vice versa.
Registering plugins to KASKO frontend framework
In order to register plugins to the KASKO frontend framework, the registerKaskoPlugin function must be called.
Interface
name
Name of the plugin.
factory
Either a factory method or a plain object containing the plugin configuration.
Examples
KASKO public service
When registering components or other attributes to KASKO frontend framework, a kasko public service is exposed via the factory method. This public service can be used to access translations, state slices, dispatch events and much more.
Interface
Using plugin components in manifest
All plugin components registered to the KASKO frontend framework become available for use in the manifest. Reference them in the manifest the same way how any internal component would be used.
Example
Using plugin validators in manifest
All plugin validators registered to the KASKO frontend framework become available for use in the manifest and field definition. Reference them in the manifest the same way how any internal validator would be used.
Example
Component properties
Almost all components need to implement some dynamic functionality that can be configured via the manifest. This can be achieved with WEB Component attributes.
NOTE: Attributes CAN be stringified JSON.
Example
Component
Usage in manifest:
Component inheritance
Sometimes custom components need to allow various content sections to be defined via manifest. For example, a panel component could have a header, body and footer section. This functionality can be achieved with slots.
Example
Component:
Usage in manifest:
Last updated