nustack

ui

nustd.ui -- component fabric.

Module nustd.ui.

nustd.ui -- component fabric.

Layout under src/nustd/ui/:

  • lens/ -- the Shape lens: LensRef, the walk that turns a Shape and a cursor into columns, and browse to assemble the two.
  • table/ -- sync: a TableRef kept equal to a kv store, live across tabs, and Row, the stored row it reads.
  • core/ -- host-independent UI fabric: Ref, Section / SectionRef, abstract Session / Subscription, wire Frame + interactions (Send / Write / Append / Remove / Changed). Reusable by any host.
  • refs/ -- layer 1, the widget kit as Refs: containers/ (Column, Row, Card, ...: open-ended children) and leaves/ (Text, Button, Table, charts, ...: drawn from props, no children). Any UI can be built from these alone. Depends only on core.
  • shapes/ -- layer 2, a declarative DSL over the container Refs: one Section per container (Row, Card, ...) that points _ref_cls at its Ref and adds named child slots.
  • nudle/ -- Page-based host: Index / Page / PageRef, the Boot term, and the serve preset that assembles a whole tree.

The uvicorn lifecycle, the book of live connections and the per-connection fold live in nustd.ws_server, which knows nothing about ui.

The browser half is not in this package. It lives in the repo's npm workspace at pkgs/ts (ui-core, ui-kit, and the nudle Vite app), and its compiled bundle ships as the separate nudle wheel.

The public entry is nustd.ui itself: the core fabric, the widget kit, the Shapes and the nudle host names are re-exported flat, so one import nustd.ui reaches everything a UI program spells. The lens is the exception and stays whole behind nustd.ui.lens, LensRef included: it is a subsystem rather than a widget, and a surface split between two names is worse than one more dot.

The host half loads on first use. Building Refs and serving them are two different jobs and only one of them needs a web server: nudle reaches nustd.ws_server, which reaches uvicorn and starlette, and that was most of what import nustd.ui cost. Plenty of processes only ever build Refs. The case that made this worth doing is a worker drawing on a connection it holds a proxy to: it pays the import on every launch and serves nothing, ever. So nudle, serve and the four page names come through __getattr__ below, and naming any of them loads the host with its server, which is what somebody naming them is asking for.

Modules

ModuleWhat
nustd.ui.lensnustd.ui.lens -- any Nu Shape, browsable as cascading columns.
nustd.ui.tablenustd.ui.table -- a table whose rows are what the store holds.

core.interactions

Module nustd.ui.core.interactions.

Wire interactions -- ops that flow over a Session on a Ref.

Full entries

NameSortCallMeaning
Appendscalar_commandAppend()Send an append frame on a Ref -- push onto a sequence.
Changedscalar_queryChanged(ref, event=None)Subscribe to client-side change notifications on a Ref.
Removescalar_commandRemove()Send a remove frame on a Ref -- drop its node and its whole subtree.
Sendscalar_commandSend()Send a frame on a Ref: its chain, and a payload built from the arguments.
Writescalar_commandWrite()Send a write frame on a Ref -- replace the value. An EMPTY value raises.

nudle.page

Module nustd.ui.nudle.page.

Top-level Shape kinds for nudle, and the term that boots one.

Full entries

NameSortCallMeaning
Bootscalar_commandBoot(shape_cls)Seed one browser's tree: clear it, name it, then one init per slot.
PageRefrefPageRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)Substrate Ref backing a Page slot on an Index.
IndexBrowser entrypoint. One per app.
PageSection an Index mounts at a route.

refs.leaves.table

Module nustd.ui.refs.leaves.table.

TableRef -- rows and columns, and the row ops that change them in place.

Full entries

NameSortCallMeaning
InsertRowscalar_commandInsertRow()Insert row before the row at index, clamped to the rows shown.
RemoveRowsscalar_commandRemoveRows()Drop the rows with these keys; keys not shown are skipped.
SetOrderscalar_commandSetOrder()Show the rows named by keys first, in that order; the rest keep theirs after.
SetRowscalar_commandSetRow()Replace the row keyed key with row, or add it last when none is shown.
TableRefrefTableRef(address, parent_ref=None, owner_shape=None, props=None)Rows and columns. The server owns the rows; the browser reports what you do.

refs.containers.chrome

Module nustd.ui.refs.containers.chrome.

Chrome containers -- Refs for the boxes that frame their children.

Full entries

NameSortCallMeaning
AccordionRefrefAccordionRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Stack of collapsible sections, each body the child at the section's id.
BoxRefrefBoxRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Styled card-like box with an optional title. Pin chrome on slot().
CardRefrefCardRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Card-styled container: title + subtitle + body children + footer.
FieldRefrefFieldRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)Label + one child input + help / error text.
FieldsetRefrefFieldsetRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Grouped fields with a legend. Display-only, server-owned.
FormRefrefFormRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Semantic form wrapper. Pin chrome on slot(); submit lives on a child ButtonRef.
ModalRefrefModalRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Dialog overlay. Open vs closed is the thing it carries, so it has a set().
TabsRefrefTabsRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Tab strip plus active body. A tab's body is the child at the tab's id.

refs.leaves.output

Module nustd.ui.refs.leaves.output.

Content leaves -- server-owned sinks that render into the body.

Full entries

NameSortCallMeaning
AlertRefrefAlertRef(address, parent_ref=None, owner_shape=None, props=None)Display banner ref. write carries partial updates; notify fires on user dismiss.
BadgeRefrefBadgeRef(address, parent_ref=None, owner_shape=None, props=None)Display-only badge ref. One write op carries every mutation.
DividerRefrefDividerRef(address, parent_ref=None, owner_shape=None, props=None)Display-only divider ref. One write op carries every mutation.
EmptyStateRefrefEmptyStateRef(address, parent_ref=None, owner_shape=None, props=None)What a region says while it has nothing to show.
GaugeRefrefGaugeRef(address, parent_ref=None, owner_shape=None, props=None)Display-only gauge ref. One write op carries every mutation.
HeadingRefrefHeadingRef(address, parent_ref=None, owner_shape=None, props=None)Display-only heading ref. One write op carries every mutation.
ImageRefrefImageRef(address, parent_ref=None, owner_shape=None, props=None)Display-only image ref. One write op carries every mutation.
JsonViewerRefrefJsonViewerRef(address, parent_ref=None, owner_shape=None, props=None)Display-only json viewer ref. One write op carries every mutation via partial-merge.
KbdRefrefKbdRef(address, parent_ref=None, owner_shape=None, props=None)One key cap, display only: a K, a ⌘, an Esc.
LinkRefrefLinkRef(address, parent_ref=None, owner_shape=None, props=None)Display-only link ref. One write op carries every mutation.
ProgressRefrefProgressRef(address, parent_ref=None, owner_shape=None, props=None)Display-only progress ref. One write op carries every mutation.
ShortcutRefrefShortcutRef(address, parent_ref=None, owner_shape=None, props=None)A key combination by key name, display only: ["mod", "K"].
StatRefrefStatRef(address, parent_ref=None, owner_shape=None, props=None)Display-only stat ref. Server-owned, single write op carries partial updates.
StatusDotRefrefStatusDotRef(address, parent_ref=None, owner_shape=None, props=None)A tone dot for a live state (connected, running, failing).
TextRefrefTextRef(address, parent_ref=None, owner_shape=None, props=None)Display-only string ref. Body copy.

refs.leaves.chart

Module nustd.ui.refs.leaves.chart.

Chart Refs -- one browser node, an ECharts option, and typed builders over it.

Full entries

NameSortCallMeaning
AreaChartrefAreaChart(address, parent_ref=None, owner_shape=None, props=None)A line chart filled underneath. stack=True for a stacked area. Same data as LineChart.
BarChartrefBarChart(address, parent_ref=None, owner_shape=None, props=None)Bars per category, one bar series per name.
BoxplotChartrefBoxplotChart(address, parent_ref=None, owner_shape=None, props=None)The spread of each category's samples: whiskers at min and max, box at the quartiles.
CandlestickChartrefCandlestickChart(address, parent_ref=None, owner_shape=None, props=None)Open, close, low and high per period.
ChartrefChart(address, parent_ref=None, owner_shape=None, props=None)A chart drawn from an ECharts option. The base every typed chart builds on.
FunnelChartrefFunnelChart(address, parent_ref=None, owner_shape=None, props=None)Stages narrowing down. Same data as PieChart.
GaugeChartrefGaugeChart(address, parent_ref=None, owner_shape=None, props=None)One value on an arc, between min and max.
HeatmapChartrefHeatmapChart(address, parent_ref=None, owner_shape=None, props=None)A grid of cells colored by value, on the sequential ramp.
HistogramrefHistogram(address, parent_ref=None, owner_shape=None, props=None)How values spread: counts per bin, binned in Python on set.
LineChartrefLineChart(address, parent_ref=None, owner_shape=None, props=None)Lines over an x axis, one per series name.
PieChartrefPieChart(address, parent_ref=None, owner_shape=None, props=None)Slices of a whole.
RadarChartrefRadarChart(address, parent_ref=None, owner_shape=None, props=None)Several measures around a circle, one shape per item.
SankeyChartrefSankeyChart(address, parent_ref=None, owner_shape=None, props=None)Flows between nodes, widths by value.
ScatterChartrefScatterChart(address, parent_ref=None, owner_shape=None, props=None)Points on two value axes, one color per series name.
SparklinerefSparkline(address, parent_ref=None, owner_shape=None, props=None)A small trend line: no axes, no grid, no tooltip. For stat cards and table cells.
SunburstChartrefSunburstChart(address, parent_ref=None, owner_shape=None, props=None)Nested rings sized by value. Same data as TreemapChart.
TreemapChartrefTreemapChart(address, parent_ref=None, owner_shape=None, props=None)Nested rectangles sized by value.

refs.leaves.display

Module nustd.ui.refs.leaves.display.

Display leaves -- small status and identity marks.

Full entries

NameSortCallMeaning
AvatarRefrefAvatarRef(address, parent_ref=None, owner_shape=None, props=None)An image for a person or thing, initials from name when it has none.
BreadcrumbRefrefBreadcrumbRef(address, parent_ref=None, owner_shape=None, props=None)The trail to here, as crumbs of {label, href}.
SkeletonRefrefSkeletonRef(address, parent_ref=None, owner_shape=None, props=None)A pulsing placeholder where content is still loading.
SpinnerRefrefSpinnerRef(address, parent_ref=None, owner_shape=None, props=None)Busy with no known progress; ProgressRef covers known progress.
StatusPillRefrefStatusPillRef(address, parent_ref=None, owner_shape=None, props=None)A state as icon + label, so it reads without color.

refs.leaves.input

Module nustd.ui.refs.leaves.input.

Input Refs -- tab-owned; server reads via read + notify path.

Full entries

NameSortCallMeaning
ButtonRefrefButtonRef(address, parent_ref=None, owner_shape=None, props=None)Click trigger; subscribe via .on_click().
CheckboxRefrefCheckboxRef(address, parent_ref=None, owner_shape=None, props=None)Boolean toggle whose checked state lives in the browser.
CodeRefrefCodeRef(address, parent_ref=None, owner_shape=None, props=None)Source code, read-only by default. Value is the text, both ways.
DatePickerRefrefDatePickerRef(address, parent_ref=None, owner_shape=None, props=None)Date input whose ISO yyyy-mm-dd value lives in the browser.
InputRefrefInputRef(address, parent_ref=None, owner_shape=None, props=None)Text input whose value lives in the browser.
MarkdownRefrefMarkdownRef(address, parent_ref=None, owner_shape=None, props=None)A markdown document, read-only by default. Value is the markdown, both ways.
NumberInputRefrefNumberInputRef(address, parent_ref=None, owner_shape=None, props=None)Numeric input whose value lives in the browser.
RadioGroupRefrefRadioGroupRef(address, parent_ref=None, owner_shape=None, props=None)Single-choice radio group whose value lives in the browser.
SelectRefrefSelectRef(address, parent_ref=None, owner_shape=None, props=None)Dropdown single-select whose value lives in the browser.
SketchRefrefSketchRef(address, parent_ref=None, owner_shape=None, props=None)A board a person draws on with a pointer; the elements live in the browser.
SliderRefrefSliderRef(address, parent_ref=None, owner_shape=None, props=None)Numeric slider whose value lives in the browser.
SwitchRefrefSwitchRef(address, parent_ref=None, owner_shape=None, props=None)On/off switch whose checked state lives in the browser.
TagInputRefrefTagInputRef(address, parent_ref=None, owner_shape=None, props=None)Multi-tag entry field whose committed list lives in the browser.
TextAreaRefrefTextAreaRef(address, parent_ref=None, owner_shape=None, props=None)Multi-line text input whose value lives in the browser.
ToggleRefrefToggleRef(address, parent_ref=None, owner_shape=None, props=None)Two-state toolbar button whose pressed state lives in the browser.

refs.containers.disclosure

Module nustd.ui.refs.containers.disclosure.

Disclosure containers -- a region that opens and closes over its children.

Full entries

NameSortCallMeaning
CollapsibleRefrefCollapsibleRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)One titled region whose children fold away.
SheetRefrefSheetRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Drawer that slides in from an edge over the page, children as its body.

refs.containers.flow

Module nustd.ui.refs.containers.flow.

Flow containers -- Refs that lay their children out and carry nothing else.

Full entries

NameSortCallMeaning
ColumnRefrefColumnRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Vertical flex layout. Pin chrome on the slot().
RowRefrefRowRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Horizontal flex layout. Pin chrome on slot().

refs.containers.base

Module nustd.ui.refs.containers.base.

ContainerRef -- the base every layout container Ref builds on.

Full entries

NameSortCallMeaning
ContainerRefrefContainerRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)Base for container Refs: open-ended children, optional chrome. Abstract.
DictContainerRefrefDictContainerRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)A container that takes its children by key. Abstract.
ListContainerRefrefListContainerRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)A container that takes its children by position. Abstract.
ShapeContainerRefrefShapeContainerRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)A container whose children are only the ones its Shape declares. Abstract.

refs.containers.grid

Module nustd.ui.refs.containers.grid.

GridRef -- children in equal cells, row after row.

Full entries

NameSortCallMeaning
GridRefrefGridRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Equal cells, one child per cell, as many per row as the width allows.

refs.leaves.base

Module nustd.ui.refs.leaves.base.

LeafRef -- the base every content, input and collection Ref builds on.

Full entries

NameSortCallMeaning
LeafRefrefLeafRef(address, parent_ref=None, owner_shape=None, props=None)Base for leaf Refs: one thing drawn from props, no children. Abstract.

refs.containers.line

Module nustd.ui.refs.containers.line.

LineRef -- inline flow: children run and wrap like words in a paragraph.

Full entries

NameSortCallMeaning
LineRefrefLineRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)Children inline, wrapping at the container's width. Pin chrome on slot().

refs.containers.list

Module nustd.ui.refs.containers.list.

ListRef -- a bulleted or numbered list whose items are any nodes.

Full entries

NameSortCallMeaning
ListRefrefListRef(address, item=None, section_cls=None, parent_ref=None, owner_shape=None, props=None)A bulleted or numbered list: string items first, then each child node.

refs.structural

Module nustd.ui.refs.structural.

Structural Refs -- bound to non-render browser APIs.

Full entries

NameSortCallMeaning
NavRefrefNavRef(address, parent_ref=None, owner_shape=None, props=None)Bound to window.history + window.location. Index-level structural Ref.
TitleRefrefTitleRef(address, parent_ref=None, owner_shape=None, props=None)Bound to document.title. Index-level structural Ref.

core.base

Module nustd.ui.core.base.

Generic UI Ref -- host-independent base for the widget kit.

Full entries

NameSortCallMeaning
RefrefRef(address, parent_ref=None, owner_shape=None, props=None)Base for Refs backed by a client rendering surface. Async-only.

core.section

Module nustd.ui.core.section.

Section -- shape-based container primitive for the UI kit.

Full entries

NameSortCallMeaning
SectionRefrefSectionRef(address, section_cls=None, parent_ref=None, owner_shape=None, props=None)Substrate Ref under every container.
SectionBase for shape-based layout primitives.

refs.leaves.tree

Module nustd.ui.refs.leaves.tree.

TreeRef -- nested rows that fold, with select, open, rename and move.

Full entries

NameSortCallMeaning
TreeRefrefTreeRef(address, parent_ref=None, owner_shape=None, props=None)Nested rows that fold. The server owns the nodes; the browser reports what you do.

shapes.chrome

Module nustd.ui.shapes.chrome.

Chrome Shapes -- Card, Box, Tabs, Modal, Accordion, Form, Fieldset, Field.

Full entries

NameCallMeaning
AccordionStack of collapsible sections, each body the child at the section's id.
BoxStyled card-like box. Pin chrome on slot().
CardCard-styled Section: title + subtitle + body slots + footer.
FieldLabel + child input + help / error text. Exactly one child slot.
FieldsetGrouped fields with a legend. Display-only, server-owned.
FormSemantic form wrapper. Pin chrome on slot(); submit lives on a child ButtonRef.
ModalDialog overlay. Pin chrome on slot(); declare body Refs as slots.
TabsTab strip plus active body, each body the child at its tab id.

shapes.disclosure

Module nustd.ui.shapes.disclosure.

Disclosure Shapes -- Collapsible and Sheet.

Full entries

NameCallMeaning
CollapsibleOne titled region whose slots fold away. Props as CollapsibleRef.slot.
SheetEdge drawer with its slots as the body. Props as SheetRef.slot.

shapes.flow

Module nustd.ui.shapes.flow.

Flow Shapes -- Column and Row, declared.

Full entries

NameCallMeaning
ColumnVertical stack of its slots. Props as ColumnRef.slot.
RowIts slots side by side. Props as RowRef.slot.

shapes.grid

Module nustd.ui.shapes.grid.

Grid Shape -- equal cells, declared.

Full entries

NameCallMeaning
GridIts slots in equal cells, row after row. Props as GridRef.slot.

shapes.line

Module nustd.ui.shapes.line.

Line Shape -- slots that run inline, wrapping like a paragraph.

Full entries

NameCallMeaning
LineIts slots inline, wrapping like a paragraph. Props as LineRef.slot.

shapes.list

Module nustd.ui.shapes.list.

List Shape -- a list whose slots are its items.

Full entries

NameCallMeaning
ListBulleted or numbered list, one item per slot. Props as ListRef.slot.

nudle.driver

Module nustd.ui.nudle.driver.

serve -- the host's two layers stacked into one tree.

Full entries

NameCallMeaning
serveui.serve(index, program, static='nudle', routes=(), host='127.0.0.1', port=8080, log_level='warning', open_browser=True, ready_timeout=10.0, shutdown_timeout=5.0)Serve program in the browser, one live arm per open tab.

On this page