@@ -62,6 +62,7 @@ ns(TL=Timeline) {
6262 # TODO: Cell
6363 type Properties(Element)
6464 type List(Element)
65+ type Tree(Element)
6566 type ProcessStatus(Element)
6667 type Progress(Element)
6768
@@ -91,9 +92,15 @@ ns(TL=Timeline) {
9192 F init(s:Scalar, ctx:_Ctx, value) _init(args())
9293 F init(c:Column, ctx:_Ctx, name:Str) _init(args())
9394 F init(p:Properties, ctx:_Ctx, props:Hash) _init(args())
95+ F init(t:Tree, ctx:_Ctx, node:Element, children:Arr) {
96+ super(t, ctx, children)
97+ t.node = node
98+ }
9499 F init(p:ProcessStatus, ctx:_Ctx, name:Str, text:AnyOf(Str, null)) _init(args()) # TODO: improve + add semantics
95100 F init(p:Progress, ctx:_Ctx, step:Int, total_steps:Int) _init(args())
96101
102+ TEST ui::Element(ui::mock_tree()).JsonData() =~ {'$type': 'Tree', 'node': {'$type': 'Scalar'}}
103+
97104
98105 F Element(ctx:_Ctx, x:AnyOf(Num, Str, Bool, Null)) Scalar(ctx, x)
99106 F Element(ctx:_Ctx, a:AnyOf(Arr, ArrLike)) List(ctx, a.map(Element(ctx, X)))
@@ -246,6 +253,23 @@ ns(TL=Timeline) {
246253 F Element(ctx:_Ctx, a:_cp::Action) Element(ctx, Str(a))
247254 }
248255
256+ section "Mock data for visual testing of Tree element" {
257+ type _MockTree
258+ F init(m:_MockTree, name:Str, children:Arr) {
259+ children.assert(Repeat(_MockTree), "_MockTree children must be _MockTree")
260+ m.name = name
261+ m.children = children
262+ }
263+
264+ F mock_tree() _MockTree("root", [
265+ _MockTree("compile", [])
266+ _MockTree("link", [_MockTree("strip", [])])
267+ _MockTree("test", [])
268+ ])
269+
270+ F Element(ctx:_Ctx, m:_MockTree) Tree(ctx, Scalar(ctx, m.name), m.children.map(Element(ctx, X)))
271+ }
272+
249273 doc Entry point to recursively convert data to UI Elements
250274 F Element(x) Element(_Ctx(), x)
251275
0 commit comments