refs.containers.base
`ContainerRef` -- the base every layout container Ref builds on.
Module nustd.ui.refs.containers.base.
ContainerRef -- the base every layout container Ref builds on.
Layer 1. A container Ref is a whole container on its own: it needs no Shape to draw, to carry chrome or to hold children.
- Children come from
parent_ref=:TextRef("t", parent_ref=row)puts a text inrow. Navigating a Shape whose_ref_clsis this Ref (page.toolbar.text) reaches the same place by way of its slots. - Repetition is free. The address is a term, so computed keys under one
parent (
RowRef(nu.Str("r") + nu.str(i), parent_ref=col)) are as many distinct children as there are keys, with nothing declared up front. - Props ride
props=on the constructor, orslot(**props)when the Ref is declared on a Shape; both go through this class's ownslot(), so the defaults and normalization live here and nowhere else. - No
set()unless one chrome value is the thing the container carries (Modal: open). The rest of its chrome isset_*.ListRefkeeps its old stringset(items)for compatibility. - How it holds children is the container's kind, one per class, the way
kv has
ShapeRef,DictRefandListRef. ADictContainerReftakes children by key, aListContainerRefby index, and aShapeContainerRefonly the ones its Shape declares. The first two may carry an item template,slot(Item)oritem=Item, andref[key]answers with anItemthere, the wayDictRef.slot(Order)answersdesks["d1"]with an Order. Declared slots are keys too, so named and templated children mix. There are no collection ops: a UI child is a component, not a value, so the kind only says how a child is reached.
The parent's flow decides how a child displays: the same Badge is a block in a Column, a cell in a Grid and a run of text in a Line. A child never says.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| ContainerRef | ref | ContainerRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None) | Base for container Refs: open-ended children, optional chrome. Abstract. |
| DictContainerRef | ref | DictContainerRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None) | A container that takes its children by key. Abstract. |
| ListContainerRef | ref | ListContainerRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None) | A container that takes its children by position. Abstract. |
| ShapeContainerRef | ref | ShapeContainerRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None) | A container whose children are only the ones its Shape declares. Abstract. |
ContainerRef
Base for container Refs: open-ended children, optional chrome. Abstract.
ContainerRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)Path nustd.ui.ContainerRef. Kind Ref, sort ref, cardinality scalar.
Something is a container only when its children are open-ended user composition. Fixed known parts (a button's label and icon) are props on a leaf instead.
Inherited methods
From nustd.ui.core.base.Ref:
| Call | Builds | Meaning |
|---|---|---|
.erase() | Nu | Drop this Ref's node on the client, and everything under it. |
Undocumented: example.
DictContainerRef
A container that takes its children by key. Abstract.
DictContainerRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Path nustd.ui.DictContainerRef. Kind Ref, sort ref, cardinality scalar.
ref[key] is the item template's child at key. The key is a term
like any address, so a computed key works too.
Methods
a[key]
Builds Ref.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
key | object |
Undocumented: summary, example.
Inherited methods
From nustd.ui.core.base.Ref:
| Call | Builds | Meaning |
|---|---|---|
.erase() | Nu | Drop this Ref's node on the client, and everything under it. |
Undocumented: example.
ListContainerRef
A container that takes its children by position. Abstract.
ListContainerRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Path nustd.ui.ListContainerRef. Kind Ref, sort ref, cardinality scalar.
ref[i] is the item template's child at index i, an int or an
int term. The browser draws indexed children in index order.
Methods
a[key]
Builds Ref.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
index | object |
Undocumented: summary, example.
Inherited methods
From nustd.ui.core.base.Ref:
| Call | Builds | Meaning |
|---|---|---|
.erase() | Nu | Drop this Ref's node on the client, and everything under it. |
Undocumented: example.
ShapeContainerRef
A container whose children are only the ones its Shape declares. Abstract.
ShapeContainerRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)Path nustd.ui.ShapeContainerRef. Kind Ref, sort ref, cardinality scalar.
It takes no item template and cannot be subscripted.
Inherited methods
From nustd.ui.core.base.Ref:
| Call | Builds | Meaning |
|---|---|---|
.erase() | Nu | Drop this Ref's node on the client, and everything under it. |
Undocumented: example.