Functions
_make_initial_fields
1
tuple[FieldState, ...]
▼
Create initial field states from specs.
_make_initial_fields
1
tuple[FieldState, ...]
▼
def _make_initial_fields(specs: tuple[FieldSpec, ...]) -> tuple[FieldState, ...]
Parameters
| Name | Type | Description |
|---|---|---|
specs |
tuple[FieldSpec, ...] |
Returns
tuple[FieldState, ...]
form_reducer
2
FormState
▼
Reducer for form state.
form_reducer
2
FormState
▼
def form_reducer(state: FormState | None, action: Action) -> FormState
Parameters
| Name | Type | Description |
|---|---|---|
state |
FormState | None |
|
action |
Action |
Returns
FormState
_handle_text_key
2
FieldState
▼
Handle keypress for text/password fields.
_handle_text_key
2
FieldState
▼
def _handle_text_key(field: FieldState, key: Key) -> FieldState
Parameters
| Name | Type | Description |
|---|---|---|
field |
FieldState |
|
key |
Key |
Returns
FieldState
_handle_select_key
3
FieldState
▼
Handle keypress for select fields.
_handle_select_key
3
FieldState
▼
def _handle_select_key(field: FieldState, key: Key, spec: FieldSpec) -> FieldState
Parameters
| Name | Type | Description |
|---|---|---|
field |
FieldState |
|
key |
Key |
|
spec |
FieldSpec |
Returns
FieldState
_handle_confirm_key
2
FieldState
▼
Handle keypress for confirm fields.
_handle_confirm_key
2
FieldState
▼
def _handle_confirm_key(field: FieldState, key: Key) -> FieldState
Parameters
| Name | Type | Description |
|---|---|---|
field |
FieldState |
|
key |
Key |
Returns
FieldState
_replace_field
3
tuple[FieldState, ...]
▼
Return a new tuple with one field replaced.
_replace_field
3
tuple[FieldState, ...]
▼
def _replace_field(fields: tuple[FieldState, ...], index: int, new: FieldState) -> tuple[FieldState, ...]
Parameters
| Name | Type | Description |
|---|---|---|
fields |
tuple[FieldState, ...] |
|
index |
int |
|
new |
FieldState |
Returns
tuple[FieldState, ...]
make_form_reducer
2
Callable
▼
Create a form reducer pre-loaded with field specs.
The returned reducer initia…
make_form_reducer
2
Callable
▼
def make_form_reducer(*specs: FieldSpec, navigate_on_submit: bool = False) -> Callable
Create a form reducer pre-loaded with field specs.
The returned reducer initializes with the given fields on @@INIT, so you don't need to pass specs via action payload.
If navigate_on_submit=True, dispatches @@NAVIGATE when the form is submitted — useful in flows where the next screen should appear automatically after form completion.
Parameters
| Name | Type | Description |
|---|---|---|
*specs |
FieldSpec |
|
navigate_on_submit |
bool |
Default:False
|
Returns
Callable
form
2
dict[str, Any]
▼
Run an interactive form, return field values.
Falls back to input() if not a T…
form
2
dict[str, Any]
▼
def form(*specs: FieldSpec, env: Any = None) -> dict[str, Any]
Run an interactive form, return field values.
Falls back to input() if not a TTY.
Parameters
| Name | Type | Description |
|---|---|---|
*specs |
FieldSpec |
|
env |
Any |
Default:None
|
Returns
dict[str, Any]
_form_fallback
1
dict[str, Any]
▼
Non-TTY fallback using input().
_form_fallback
1
dict[str, Any]
▼
def _form_fallback(specs: tuple[FieldSpec, ...] | tuple) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
specs |
tuple[FieldSpec, ...] | tuple |
Returns
dict[str, Any]