forked from kscience/visionforge
Properly treat prototype styles in editor
This commit is contained in:
parent
346b61724f
commit
1e183107cf
@ -4,6 +4,7 @@ import hep.dataforge.meta.descriptors.NodeDescriptor
|
||||
import hep.dataforge.vision.*
|
||||
import hep.dataforge.vision.react.metaViewer
|
||||
import hep.dataforge.vision.react.propertyEditor
|
||||
import hep.dataforge.vision.solid.SolidReference
|
||||
import org.w3c.dom.Element
|
||||
import react.RBuilder
|
||||
import react.dom.render
|
||||
@ -22,7 +23,11 @@ public fun RBuilder.visionPropertyEditor(
|
||||
descriptor = descriptor,
|
||||
key = key)
|
||||
}
|
||||
val styles = vision.styles
|
||||
val styles = if (vision is SolidReference) {
|
||||
(vision.styles + vision.prototype.styles).distinct()
|
||||
} else {
|
||||
vision.styles
|
||||
}
|
||||
if (styles.isNotEmpty()) {
|
||||
card("Styles") {
|
||||
accordion("styles") {
|
||||
|
@ -65,11 +65,12 @@ private val PropertyEditorItem: FunctionalComponent<PropertyEditorProps> =
|
||||
|
||||
private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
|
||||
var expanded: Boolean by useState { true }
|
||||
val itemName by useState { props.name ?: Name.EMPTY }
|
||||
val itemName = useMemo( { props.name ?: Name.EMPTY }, arrayOf(props.name))
|
||||
var item: MetaItem? by useState { props.provider.getItem(itemName) }
|
||||
val descriptorItem: ItemDescriptor? = props.descriptor?.get(itemName)
|
||||
val descriptorItem: ItemDescriptor? =
|
||||
useMemo({ props.descriptor?.get(itemName) }, arrayOf(props.descriptor, itemName))
|
||||
|
||||
if(descriptorItem?.hidden == true) return //fail fast for hidden property
|
||||
if (descriptorItem?.hidden == true) return //fail fast for hidden property
|
||||
|
||||
var actualItem: MetaItem? by useState {
|
||||
item ?: props.defaultProvider?.getItem(itemName) ?: descriptorItem?.defaultItem()
|
||||
@ -79,7 +80,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
|
||||
|
||||
fun update() {
|
||||
item = props.provider.getItem(itemName)
|
||||
actualItem = item ?: descriptorItem?.defaultItem()
|
||||
actualItem = item ?: props.defaultProvider?.getItem(itemName) ?: descriptorItem?.defaultItem()
|
||||
}
|
||||
|
||||
if (props.updateFlow != null) {
|
||||
|
@ -20,17 +20,17 @@ import styled.styledInput
|
||||
import styled.styledSelect
|
||||
|
||||
public external interface ValueChooserProps : RProps {
|
||||
var item: MetaItem?
|
||||
var descriptor: ValueDescriptor?
|
||||
var valueChanged: ((Value?) -> Unit)?
|
||||
public var item: MetaItem?
|
||||
public var descriptor: ValueDescriptor?
|
||||
public var valueChanged: ((Value?) -> Unit)?
|
||||
}
|
||||
|
||||
public external interface ValueChooserState : RState {
|
||||
var rawInput: Boolean?
|
||||
public var rawInput: Boolean?
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class ValueChooserComponent(props: ValueChooserProps) : RComponent<ValueChooserProps, ValueChooserState>(props) {
|
||||
public class ValueChooserComponent(props: ValueChooserProps) : RComponent<ValueChooserProps, ValueChooserState>(props) {
|
||||
private val element = createRef<HTMLElement>()
|
||||
|
||||
private fun getValue(): Value? {
|
||||
|
Loading…
Reference in New Issue
Block a user