|
|
|
|
@ -20,16 +20,34 @@ tree = config \
|
|
|
|
|
| ConstructorValue { tag = tag } \ simple tag "#fc6"
|
|
|
|
|
| FunctionValue _ \ simple "<fn>" "#888"
|
|
|
|
|
| RecordValue entries \
|
|
|
|
|
ui.column {
|
|
|
|
|
gap = 0,
|
|
|
|
|
children = map (entry \
|
|
|
|
|
(valueLabel entry.value)
|
|
|
|
|
| Some label \ simple (entry.key & " = " & label) "#aaa"
|
|
|
|
|
| None \ ui.column { gap = 0, children = [
|
|
|
|
|
simple entry.key "#aaa",
|
|
|
|
|
tree { value = entry.value, depth = depth + 1 }
|
|
|
|
|
]}
|
|
|
|
|
) entries
|
|
|
|
|
ui.stateful {
|
|
|
|
|
key = "tree-" & config.path,
|
|
|
|
|
init = { collapsed = True },
|
|
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
|
| Clicked _ \ (
|
|
|
|
|
_ = debug "clicked on node" [];
|
|
|
|
|
{ state = state.{ collapsed = (not state.collapsed) }, emit = [] }
|
|
|
|
|
)
|
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
|
|
view = state \
|
|
|
|
|
ui.column {
|
|
|
|
|
gap = 0,
|
|
|
|
|
children = [
|
|
|
|
|
simple ((state.collapsed | True \ "▶ " | False \ "▼ ") & (show (len entries)) & " fields") "#888",
|
|
|
|
|
...(state.collapsed
|
|
|
|
|
| True \ []
|
|
|
|
|
| False \ map (entry \
|
|
|
|
|
(valueLabel entry.value)
|
|
|
|
|
| Some label \ simple (entry.key & " = " & label) "#aaa"
|
|
|
|
|
| None \ ui.column { gap = 0, children = [
|
|
|
|
|
simple entry.key "#aaa",
|
|
|
|
|
tree { value = entry.value, depth = depth + 1, path = config.path & "." & entry.key }
|
|
|
|
|
]}
|
|
|
|
|
) entries)
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
| ListValue items \
|
|
|
|
|
ui.column {
|
|
|
|
|
|