|
|
|
@ -1,4 +1,32 @@
|
|
|
|
tree = config \
|
|
|
|
treeNodeHeight = value path expanded \
|
|
|
|
|
|
|
|
lineH = 20;
|
|
|
|
|
|
|
|
valueLabel = v \ v
|
|
|
|
|
|
|
|
| NumberValue n \ Some n
|
|
|
|
|
|
|
|
| StringValue n \ Some n
|
|
|
|
|
|
|
|
| ConstructorValue { tag = tag } \ Some tag
|
|
|
|
|
|
|
|
| FunctionValue _ \ Some "<fn>"
|
|
|
|
|
|
|
|
| _ \ None;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value
|
|
|
|
|
|
|
|
| RecordValue entries \
|
|
|
|
|
|
|
|
(contains path expanded)
|
|
|
|
|
|
|
|
| True \ lineH + (sum (map (entry \
|
|
|
|
|
|
|
|
(valueLabel entry.value)
|
|
|
|
|
|
|
|
| Some _ \ lineH
|
|
|
|
|
|
|
|
| None \ lineH + (treeNodeHeight entry.value (path & "." & entry.key) expanded)
|
|
|
|
|
|
|
|
) entries))
|
|
|
|
|
|
|
|
| False \ lineH
|
|
|
|
|
|
|
|
| ListValue items \
|
|
|
|
|
|
|
|
(contains path expanded)
|
|
|
|
|
|
|
|
| True \ lineH + (sum (mapWithIndex (item i \
|
|
|
|
|
|
|
|
(valueLabel item)
|
|
|
|
|
|
|
|
| Some _ \ lineH
|
|
|
|
|
|
|
|
| None \ lineH + (treeNodeHeight item (path & "." & (show i)) expanded)
|
|
|
|
|
|
|
|
) items))
|
|
|
|
|
|
|
|
| False \ lineH
|
|
|
|
|
|
|
|
| _ \ lineH;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
treeNode = config \
|
|
|
|
depth = config.depth;
|
|
|
|
depth = config.depth;
|
|
|
|
indent = depth * 20;
|
|
|
|
indent = depth * 20;
|
|
|
|
|
|
|
|
|
|
|
|
@ -14,51 +42,76 @@ tree = config \
|
|
|
|
| FunctionValue _ \ Some "<fn>"
|
|
|
|
| FunctionValue _ \ Some "<fn>"
|
|
|
|
| _ \ None;
|
|
|
|
| _ \ None;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
header = isExp label color \
|
|
|
|
|
|
|
|
ui.clickable {
|
|
|
|
|
|
|
|
onClick = _ \ config.onToggle config.path,
|
|
|
|
|
|
|
|
child = simple ((isExp | True \ "▼ " | False \ "▶ ") & label) color
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isExp = contains config.path config.expanded;
|
|
|
|
|
|
|
|
|
|
|
|
config.value
|
|
|
|
config.value
|
|
|
|
| NumberValue n \ simple (show n) "#6cf"
|
|
|
|
| NumberValue n \ simple (show n) "#6cf"
|
|
|
|
| StringValue n \ simple ("\"" & n & "\"") "#f6a"
|
|
|
|
| StringValue n \ simple ("\"" & n & "\"") "#f6a"
|
|
|
|
| ConstructorValue { tag = tag } \ simple tag "#fc6"
|
|
|
|
| ConstructorValue { tag = tag } \ simple tag "#fc6"
|
|
|
|
| FunctionValue _ \ simple "<fn>" "#888"
|
|
|
|
| FunctionValue _ \ simple "<fn>" "#888"
|
|
|
|
| RecordValue entries \
|
|
|
|
| RecordValue entries \
|
|
|
|
ui.stateful {
|
|
|
|
ui.column { gap = 0, children = [
|
|
|
|
key = "tree-" & config.path,
|
|
|
|
header isExp ((show (len entries)) & " fields") "#888",
|
|
|
|
init = { collapsed = True },
|
|
|
|
...(isExp
|
|
|
|
|
|
|
|
| True \ [ui.clickable {
|
|
|
|
update = state event \ event
|
|
|
|
onClick = _ \ noOp,
|
|
|
|
| Clicked _ \ (
|
|
|
|
child = ui.column { gap = 0, children = map (entry \
|
|
|
|
_ = 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)
|
|
|
|
(valueLabel entry.value)
|
|
|
|
| Some label \ simple (entry.key & " = " & label) "#aaa"
|
|
|
|
| Some label \ simple (entry.key & " = " & label) "#aaa"
|
|
|
|
| None \ ui.column { gap = 0, children = [
|
|
|
|
| None \ ui.column { gap = 0, children = [
|
|
|
|
simple entry.key "#aaa",
|
|
|
|
simple entry.key "#aaa",
|
|
|
|
tree { value = entry.value, depth = depth + 1, path = config.path & "." & entry.key }
|
|
|
|
treeNode { value = entry.value, depth = depth + 1, path = config.path & "." & entry.key, expanded = config.expanded, onToggle = config.onToggle }
|
|
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
) entries }
|
|
|
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
| False \ [])
|
|
|
|
]}
|
|
|
|
]}
|
|
|
|
) entries)
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
| ListValue items \
|
|
|
|
| ListValue items \
|
|
|
|
ui.column {
|
|
|
|
ui.column { gap = 0, children = [
|
|
|
|
gap = 0,
|
|
|
|
header isExp ((show (len items)) & " items") "#888",
|
|
|
|
children = mapWithIndex (item i \
|
|
|
|
...(isExp
|
|
|
|
|
|
|
|
| True \ [ui.clickable {
|
|
|
|
|
|
|
|
onClick = _ \ noOp,
|
|
|
|
|
|
|
|
child = ui.column { gap = 0, children = mapWithIndex (item i \
|
|
|
|
(valueLabel item)
|
|
|
|
(valueLabel item)
|
|
|
|
| Some label \ simple ((show i) & " : " & label) "#aaa"
|
|
|
|
| Some label \ simple ((show i) & " : " & label) "#aaa"
|
|
|
|
| None \ ui.column { gap = 0, children = [
|
|
|
|
| None \ ui.column { gap = 0, children = [
|
|
|
|
simple (show i) "#aaa",
|
|
|
|
simple (show i) "#aaa",
|
|
|
|
tree { value = item, depth = depth + 1 }
|
|
|
|
treeNode { value = item, depth = depth + 1, path = config.path & "." & (show i), expanded = config.expanded, onToggle = config.onToggle }
|
|
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
) items }
|
|
|
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
| False \ [])
|
|
|
|
]}
|
|
|
|
]}
|
|
|
|
) items
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
| _ \ ui.text { content = "?", color = "#666" };
|
|
|
|
| _ \ ui.text { content = "?", color = "#666" };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tree = config \
|
|
|
|
|
|
|
|
ui.stateful {
|
|
|
|
|
|
|
|
key = "tree-" & config.path,
|
|
|
|
|
|
|
|
init = { expanded = [] },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
|
|
|
|
| Toggle path \ ((contains path state.expanded)
|
|
|
|
|
|
|
|
| True \ { state = state.{ expanded = filter (p \ p != path) state.expanded }, emit = [] }
|
|
|
|
|
|
|
|
| False \ { state = state.{ expanded = [path, ...state.expanded] }, emit = [] })
|
|
|
|
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view = state emit \
|
|
|
|
|
|
|
|
onToggle = path \ emit (Toggle path);
|
|
|
|
|
|
|
|
totalH = treeNodeHeight config.value config.path state.expanded;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scrollable {
|
|
|
|
|
|
|
|
w = config.w,
|
|
|
|
|
|
|
|
h = config.h,
|
|
|
|
|
|
|
|
totalWidth = config.w,
|
|
|
|
|
|
|
|
totalHeight = totalH,
|
|
|
|
|
|
|
|
onScroll = _ \ noOp,
|
|
|
|
|
|
|
|
child = treeNode { value = config.value, path = config.path, depth = 0, expanded = state.expanded, onToggle = onToggle }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|