Add TextInput example exposing type system limitations + roadmap

Created a new example that demonstrates what we need for proper string/type support:

**TextInput Example (currently a counter):**
- Initially tried to build reactive text input
- Exposed 5 critical limitations:
  1. String signals stored as i32 (should be i8*)
  2. F-string interpolation incomplete (f"Count: {count}" → "0")
  3. No oninput event (only onclick supported)
  4. No event value passing (can't get input.value)
  5. No string operations (len, concat, etc.)

**Quick Fix Applied:**
- Added type coercion in _emit_signal_globals()
- String signals default to i32 0 (temporary)
- Bool signals convert True/False to 1/0
- Example now uses counter to demonstrate reactive updates

**TYPE_SYSTEM_ROADMAP.md:**
Complete implementation plan for proper type support:
- Phase 1: Type hints extraction (already works!)
- Phase 2: Typed signals (i32, i8*, i1)
- Phase 3: String interpolation in text nodes
- Phase 4: Generalized event system
- Phase 5: Component parameter type checking
- Phase 6: Delegate/callback types

This example will drive the type system implementation. Once complete,
text input will work with proper string signals and reactive updates.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Aaron SinclairandClaude committed 2025-11-15 11:53:56 -08:00
1 parent 134ddc4c42
commit 443cca5662
7 files changed
+579

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
"""
TextInput example - Reactive counter to demonstrate what we need for text input.
Current limitations exposed by this example:
1. No oninput event (only onclick) - need generalized event handling
2. No string signals (only i32) - need type system
3. No f-string interpolation with signals in text nodes
4. No event value passing (onclick doesn't pass event data)
5. No string operations (len, concat, etc.)
For now, using a counter to demonstrate the reactive infrastructure
that text input will use once we implement string support.
"""
from ritz.syntax import *
@component
def TextInput():
"""Counter that demonstrates reactive updates (placeholder for text input)."""
count = signal(0) # Integer signal - works!
def increment():
"""Increment counter."""
count = count + 1
def decrement():
"""Decrement counter."""
count = count - 1
with Div(class_="container"):
with H1():
yield "Reactive Counter"
with P(class_="instructions"):
yield "Click buttons to see reactive updates (text input coming soon!):"
# Buttons (placeholder for text input)
with Div(class_="button-group"):
with Button(onclick=decrement):
yield "−"
with P(class_="counter-display"):
yield f"Count: {count}"
with Button(onclick=increment):
yield "+"
# Info about what we need
with P(class_="todo"):
yield "TODO: Replace with text input once we implement:"
with Ul(class_="todo-list"):
with Li():
yield "1. String signals (i8* not i32)"
with Li():
yield "2. oninput event handler"
with Li():
yield "3. Event value passing"
with Li():
yield "4. F-string interpolation with signals"