feat: dynamic mode

This commit is contained in:
2026-04-01 08:28:44 +02:00
parent df11705875
commit 619d3ec538
16 changed files with 1184 additions and 38 deletions

View File

@@ -237,7 +237,121 @@ class Status(IRNode):
@dataclass
class Table(IRNode):
"""Box-drawn table (Phase 4)."""
"""Box-drawn table."""
title: str = ""
columns: list[tuple[str, int]] = field(default_factory=list) # (name, width)
rows: list[list[str]] = field(default_factory=list)
# ---------------------------------------------------------------------------
# Form nodes
# ---------------------------------------------------------------------------
@dataclass
class Form(IRNode):
"""Form container grouping interactive fields."""
form_name: str = ""
@dataclass
class Field(IRNode):
"""Text input field."""
field_name: str = ""
field_width: int = 24
placeholder: str = ""
@dataclass
class Password(IRNode):
"""Masked password field."""
field_name: str = ""
field_width: int = 24
placeholder: str = ""
@dataclass
class Radio(IRNode):
"""Radio button group — options separated by |."""
group: str = ""
options: list[str] = field(default_factory=list)
@dataclass
class Checkbox(IRNode):
"""Checkbox field."""
field_name: str = ""
checkbox_label: str = ""
checked: bool = False
@dataclass
class FormButton(IRNode):
"""Submit button — clickable link in Micron."""
button_label: str = ""
dest: str = ""
# ---------------------------------------------------------------------------
# Dynamic nodes (Phase 7)
# ---------------------------------------------------------------------------
class SourceType(Enum):
SHELL = auto()
FILE = auto()
JSON = auto()
PYTHON = auto()
RNS = auto()
PARAM = auto()
@dataclass
class Let(IRNode):
"""Variable assignment: let name = "value" or let name = 1,2,3."""
var_name: str = ""
var_value: str = ""
@dataclass
class Source(IRNode):
"""Data source resolved at render time (dynamic pages only)."""
var_name: str = ""
source_type: SourceType = SourceType.SHELL
command: str = ""
timeout: int = 5
@dataclass
class IfBlock(IRNode):
"""Conditional block: if $var > threshold."""
condition: str = ""
# children = the "then" branch
elif_branches: list[tuple[str, list[IRNode]]] = field(default_factory=list)
else_children: list[IRNode] = field(default_factory=list)
@dataclass
class ForLoop(IRNode):
"""Iteration: for item in $collection."""
var_name: str = ""
iterable: str = ""
# children = loop body
@dataclass
class CacheControl(IRNode):
"""Cache header: cache 0 (never cache) or cache 300 (5 min)."""
seconds: int = 0
@dataclass
class OnSubmit(IRNode):
"""Form submission handler: on_submit "form_name"."""
form_name: str = ""
# children = handler body
@dataclass
class StateDecl(IRNode):
"""State persistence: state "name" "/path.json"."""
state_name: str = ""
path: str = ""