accept dict str str
This commit is contained in:
parent
b09907c269
commit
cbdaca7596
@ -111,6 +111,15 @@ def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]:
|
|||||||
return (FORM_DATA,)
|
return (FORM_DATA,)
|
||||||
|
|
||||||
|
|
||||||
|
def on_submit_string_event_spec() -> Tuple[Var[Dict[str, str]]]:
|
||||||
|
"""Event handler spec for the on_submit event.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The event handler spec.
|
||||||
|
"""
|
||||||
|
return (FORM_DATA,)
|
||||||
|
|
||||||
|
|
||||||
class Form(BaseHTML):
|
class Form(BaseHTML):
|
||||||
"""Display the form element."""
|
"""Display the form element."""
|
||||||
|
|
||||||
@ -150,7 +159,7 @@ class Form(BaseHTML):
|
|||||||
handle_submit_unique_name: Var[str]
|
handle_submit_unique_name: Var[str]
|
||||||
|
|
||||||
# Fired when the form is submitted
|
# Fired when the form is submitted
|
||||||
on_submit: EventHandler[on_submit_event_spec]
|
on_submit: EventHandler[on_submit_event_spec, on_submit_string_event_spec]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, *children, **props):
|
def create(cls, *children, **props):
|
||||||
|
@ -271,6 +271,7 @@ class Fieldset(Element):
|
|||||||
...
|
...
|
||||||
|
|
||||||
def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]: ...
|
def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]: ...
|
||||||
|
def on_submit_string_event_spec() -> Tuple[Var[Dict[str, str]]]: ...
|
||||||
|
|
||||||
class Form(BaseHTML):
|
class Form(BaseHTML):
|
||||||
@overload
|
@overload
|
||||||
@ -337,7 +338,9 @@ class Form(BaseHTML):
|
|||||||
on_mouse_over: Optional[EventType[[]]] = None,
|
on_mouse_over: Optional[EventType[[]]] = None,
|
||||||
on_mouse_up: Optional[EventType[[]]] = None,
|
on_mouse_up: Optional[EventType[[]]] = None,
|
||||||
on_scroll: Optional[EventType[[]]] = None,
|
on_scroll: Optional[EventType[[]]] = None,
|
||||||
on_submit: Optional[EventType[Dict[str, Any]]] = None,
|
on_submit: Optional[
|
||||||
|
Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]]
|
||||||
|
] = None,
|
||||||
on_unmount: Optional[EventType[[]]] = None,
|
on_unmount: Optional[EventType[[]]] = None,
|
||||||
**props,
|
**props,
|
||||||
) -> "Form":
|
) -> "Form":
|
||||||
|
@ -129,7 +129,9 @@ class FormRoot(FormComponent, HTMLForm):
|
|||||||
on_mouse_over: Optional[EventType[[]]] = None,
|
on_mouse_over: Optional[EventType[[]]] = None,
|
||||||
on_mouse_up: Optional[EventType[[]]] = None,
|
on_mouse_up: Optional[EventType[[]]] = None,
|
||||||
on_scroll: Optional[EventType[[]]] = None,
|
on_scroll: Optional[EventType[[]]] = None,
|
||||||
on_submit: Optional[EventType[Dict[str, Any]]] = None,
|
on_submit: Optional[
|
||||||
|
Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]]
|
||||||
|
] = None,
|
||||||
on_unmount: Optional[EventType[[]]] = None,
|
on_unmount: Optional[EventType[[]]] = None,
|
||||||
**props,
|
**props,
|
||||||
) -> "FormRoot":
|
) -> "FormRoot":
|
||||||
@ -594,7 +596,9 @@ class Form(FormRoot):
|
|||||||
on_mouse_over: Optional[EventType[[]]] = None,
|
on_mouse_over: Optional[EventType[[]]] = None,
|
||||||
on_mouse_up: Optional[EventType[[]]] = None,
|
on_mouse_up: Optional[EventType[[]]] = None,
|
||||||
on_scroll: Optional[EventType[[]]] = None,
|
on_scroll: Optional[EventType[[]]] = None,
|
||||||
on_submit: Optional[EventType[Dict[str, Any]]] = None,
|
on_submit: Optional[
|
||||||
|
Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]]
|
||||||
|
] = None,
|
||||||
on_unmount: Optional[EventType[[]]] = None,
|
on_unmount: Optional[EventType[[]]] = None,
|
||||||
**props,
|
**props,
|
||||||
) -> "Form":
|
) -> "Form":
|
||||||
@ -716,7 +720,9 @@ class FormNamespace(ComponentNamespace):
|
|||||||
on_mouse_over: Optional[EventType[[]]] = None,
|
on_mouse_over: Optional[EventType[[]]] = None,
|
||||||
on_mouse_up: Optional[EventType[[]]] = None,
|
on_mouse_up: Optional[EventType[[]]] = None,
|
||||||
on_scroll: Optional[EventType[[]]] = None,
|
on_scroll: Optional[EventType[[]]] = None,
|
||||||
on_submit: Optional[EventType[Dict[str, Any]]] = None,
|
on_submit: Optional[
|
||||||
|
Union[EventType[Dict[str, Any]], EventType[Dict[str, str]]]
|
||||||
|
] = None,
|
||||||
on_unmount: Optional[EventType[[]]] = None,
|
on_unmount: Optional[EventType[[]]] = None,
|
||||||
**props,
|
**props,
|
||||||
) -> "Form":
|
) -> "Form":
|
||||||
|
@ -1104,7 +1104,7 @@ def call_event_handler(
|
|||||||
if event_spec_return_types:
|
if event_spec_return_types:
|
||||||
failures = []
|
failures = []
|
||||||
|
|
||||||
for event_spec_return_type in event_spec_return_types:
|
for i, event_spec_return_type in enumerate(event_spec_return_types):
|
||||||
args = get_args(event_spec_return_type)
|
args = get_args(event_spec_return_type)
|
||||||
|
|
||||||
args_types_without_vars = [
|
args_types_without_vars = [
|
||||||
@ -1146,6 +1146,11 @@ def call_event_handler(
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not failed_type_check:
|
if not failed_type_check:
|
||||||
|
if i:
|
||||||
|
console.warn(
|
||||||
|
f"Event handler {key} expects {args_types_without_vars} but got {type_hints_of_provided_callback} as annotated in {event_handler.fn.__qualname__} instead. "
|
||||||
|
f"This may lead to unexpected behavior but is intentionally ignored for {key}."
|
||||||
|
)
|
||||||
return event_handler(*parsed_args)
|
return event_handler(*parsed_args)
|
||||||
|
|
||||||
if failures:
|
if failures:
|
||||||
|
Loading…
Reference in New Issue
Block a user