Worksheet
The Worksheet modality arranges components on a grid and compiles them into a linear sequence of worksheet elements. It implements all three core traits — Reducer, Component, and Modality — on a single struct.
Type Summary
Section titled “Type Summary”| Associated Type | Concrete Type |
|---|---|
Synced | WorksheetSynced |
Ephemeral | WorksheetEphemeral |
Position | GridPosition |
ChildComponent | dyn WorksheetComponent |
Component::Metadata | WorksheetMetadata |
Component::Output | Vec<WorksheetElement> |
Snapshot | WorksheetSnapshot |
Session type: Session<Worksheet, SessionIntent<WorksheetIntent>>
Struct
Section titled “Struct”pub struct Worksheet { state: State<WorksheetSynced, WorksheetEphemeral>,}Position
Section titled “Position”GridPosition describes where a component sits on the worksheet grid:
pub struct GridPosition { pub row: u32, pub col: u32, // grid span, etc.}Implements Clone, PartialEq, Hash, Describe. Describe output: "row 2, col 3".
Synced State
Section titled “Synced State”pub struct WorksheetSynced { pub placements: Vec<ComponentPlacement<GridPosition>>, // resource metadata (HasResourceMeta)}Each placement has a component_key (e.g. "question", "section_heading") and optional component_id for customized instances.
Elements
Section titled “Elements”The compiled output is a sequence of WorksheetElement values (renamed from WorksheetNode):
pub enum WorksheetElement { Question(QuestionElement), SectionHeading(SectionHeadingElement), // ... additional variants}Compilation and Grid Math
Section titled “Compilation and Grid Math”The worksheet keeps its own compile context for grid layout math. WorksheetMetadata captures the grid parameters used as the modality-level Component::Metadata:
pub struct WorksheetMetadata { pub cell_width: f64, pub cell_height: f64, pub margin: f64, // grid dimensions, node bounds, etc.}WorksheetMetadata: Hash enables the incremental compilation cache on Session. When the grid parameters change, the entire worksheet recompiles; when only a single placement changes, only that component recompiles.
The layout() default iterates placements, resolves bindings, and delegates to compile_child. assemble() collects the per-component WorksheetElement outputs into Vec<WorksheetElement>.
fn compile_child( &self, placement: &ComponentPlacement<GridPosition>, _meta: &(), values: &HashMap<String, PropertyValue>,) -> Result<WorksheetElement, CompileError> { let component = resolve_component(&placement.component_key); component.compile(&(), values)}Related
Section titled “Related”- Intents — all
WorksheetIntentvariants - Components — the
WorksheetComponentsubtrait and built-ins Reducer— state management via the Genvoy patternCommand— the universal envelope wrappingWorksheetIntentFRB Patterns— how worksheet types cross the Dart/Rust boundary