Fix bug with ElementVisionRenderer having the same name
This commit is contained in:
parent
f0db286ce6
commit
1145483a90
@ -10,7 +10,7 @@ val dataforgeVersion by extra("0.8.0")
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "space.kscience"
|
group = "space.kscience"
|
||||||
version = "0.4.0"
|
version = "0.4.1-dev-1"
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
@ -23,6 +23,7 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api("app.softwork:bootstrap-compose:0.1.15")
|
api("app.softwork:bootstrap-compose:0.1.15")
|
||||||
api("app.softwork:bootstrap-compose-icons:0.1.15")
|
api("app.softwork:bootstrap-compose-icons:0.1.15")
|
||||||
|
implementation(compose.html.svg)
|
||||||
|
|
||||||
api(compose.html.core)
|
api(compose.html.core)
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@ public interface ElementVisionRenderer {
|
|||||||
meta: Meta = Meta.EMPTY,
|
meta: Meta = Meta.EMPTY,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
override fun toString(): String
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
public const val TYPE: String = "elementVisionRenderer"
|
public const val TYPE: String = "elementVisionRenderer"
|
||||||
public const val ZERO_RATING: Int = 0
|
public const val ZERO_RATING: Int = 0
|
||||||
@ -66,6 +68,8 @@ public class SingleTypeVisionRenderer<T : Vision>(
|
|||||||
renderFunction(name, kClass.cast(vision), meta)
|
renderFunction(name, kClass.cast(vision), meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "ElementVisionRender(${kClass.simpleName})"
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun <reified T : Vision> ElementVisionRenderer(
|
public inline fun <reified T : Vision> ElementVisionRenderer(
|
||||||
|
@ -41,16 +41,15 @@ private fun HTMLInputElement.subscribeToInput(inputVision: VisionOfHtmlInput) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val htmlVisionRenderer: ElementVisionRenderer =
|
internal val htmlVisionRenderer: ElementVisionRenderer = ElementVisionRenderer<VisionOfPlainHtml> { _, vision, _ ->
|
||||||
ElementVisionRenderer<VisionOfPlainHtml> { _, vision, _ ->
|
div().also { div ->
|
||||||
div().also { div ->
|
div.subscribeToVision(vision)
|
||||||
div.subscribeToVision(vision)
|
vision.useProperty(VisionOfPlainHtml::content) {
|
||||||
vision.useProperty(VisionOfPlainHtml::content) {
|
div.clear()
|
||||||
div.clear()
|
if (it != null) div.innerHTML = it
|
||||||
if (it != null) div.innerHTML = it
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal val inputVisionRenderer: ElementVisionRenderer = ElementVisionRenderer<VisionOfHtmlInput>(
|
internal val inputVisionRenderer: ElementVisionRenderer = ElementVisionRenderer<VisionOfHtmlInput>(
|
||||||
acceptRating = ElementVisionRenderer.DEFAULT_RATING - 1
|
acceptRating = ElementVisionRenderer.DEFAULT_RATING - 1
|
||||||
|
@ -31,7 +31,7 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer {
|
|||||||
else -> ElementVisionRenderer.ZERO_RATING
|
else -> ElementVisionRenderer.ZERO_RATING
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(element: Element,name: Name, vision: Vision, meta: Meta) {
|
override fun render(element: Element, name: Name, vision: Vision, meta: Meta) {
|
||||||
require(vision is VisionOfMarkup) { "The vision is not a markup vision" }
|
require(vision is VisionOfMarkup) { "The vision is not a markup vision" }
|
||||||
val div = document.createElement("div")
|
val div = document.createElement("div")
|
||||||
val flavour = when (vision.format) {
|
val flavour = when (vision.format) {
|
||||||
@ -49,6 +49,8 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer {
|
|||||||
element.append(div)
|
element.append(div)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "Markup"
|
||||||
|
|
||||||
override fun content(target: String): Map<Name, Any> = when (target) {
|
override fun content(target: String): Map<Name, Any> = when (target) {
|
||||||
ElementVisionRenderer.TYPE -> mapOf("markup".asName() to this)
|
ElementVisionRenderer.TYPE -> mapOf("markup".asName() to this)
|
||||||
else -> super.content(target)
|
else -> super.content(target)
|
||||||
|
@ -33,6 +33,8 @@ public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer {
|
|||||||
element.plot(config, plot)
|
element.plot(config, plot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "Plotly"
|
||||||
|
|
||||||
override fun content(target: String): Map<Name, Any> = when (target) {
|
override fun content(target: String): Map<Name, Any> = when (target) {
|
||||||
ElementVisionRenderer.TYPE -> mapOf("plotly".asName() to this)
|
ElementVisionRenderer.TYPE -> mapOf("plotly".asName() to this)
|
||||||
else -> super.content(target)
|
else -> super.content(target)
|
||||||
|
@ -81,6 +81,8 @@ public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer {
|
|||||||
TabulatorFull(element as HTMLElement, tableOptions)
|
TabulatorFull(element as HTMLElement, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "Table"
|
||||||
|
|
||||||
override fun content(target: String): Map<Name, Any> = when (target) {
|
override fun content(target: String): Map<Name, Any> = when (target) {
|
||||||
ElementVisionRenderer.TYPE -> mapOf("table".asName() to this)
|
ElementVisionRenderer.TYPE -> mapOf("table".asName() to this)
|
||||||
else -> super.content(target)
|
else -> super.content(target)
|
||||||
|
@ -169,6 +169,8 @@ public class ThreePlugin : AbstractPlugin(), ComposeHtmlVisionRenderer {
|
|||||||
override fun rateVision(vision: Vision): Int =
|
override fun rateVision(vision: Vision): Int =
|
||||||
if (vision is Solid) ElementVisionRenderer.DEFAULT_RATING else ElementVisionRenderer.ZERO_RATING
|
if (vision is Solid) ElementVisionRenderer.DEFAULT_RATING else ElementVisionRenderer.ZERO_RATING
|
||||||
|
|
||||||
|
override fun toString(): String = "ThreeJS"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the given [Solid] Vision in a [ThreeCanvas] attached
|
* Render the given [Solid] Vision in a [ThreeCanvas] attached
|
||||||
* to the [element]. Canvas objects are cached, so subsequent calls
|
* to the [element]. Canvas objects are cached, so subsequent calls
|
||||||
|
@ -32,8 +32,8 @@ kscience {
|
|||||||
|
|
||||||
jsMain {
|
jsMain {
|
||||||
api(projects.visionforgeThreejs)
|
api(projects.visionforgeThreejs)
|
||||||
implementation(npm("file-saver", "2.0.5"))
|
api(npm("file-saver", "2.0.5"))
|
||||||
implementation(npm("@types/file-saver", "2.0.7"))
|
api(npm("@types/file-saver", "2.0.7"))
|
||||||
compileOnly(npm("webpack-bundle-analyzer", "4.5.0"))
|
compileOnly(npm("webpack-bundle-analyzer", "4.5.0"))
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user