sub form.root to form class solely for documentation ()

This commit is contained in:
Martin Xu 2024-02-13 12:03:17 -08:00 committed by GitHub
parent c1089fc8f9
commit fda6785d56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 104 additions and 6 deletions
reflex/components/radix/primitives

View File

@ -290,16 +290,24 @@ class FormSubmit(FormComponent):
alias = "RadixFormSubmit"
class Form(SimpleNamespace):
# This class is created mainly for reflex-web docs.
class Form(FormRoot):
"""The Form component."""
pass
class FormNamespace(SimpleNamespace):
"""Form components."""
root = __call__ = staticmethod(FormRoot.create)
root = staticmethod(FormRoot.create)
control = staticmethod(FormControl.create)
field = staticmethod(FormField.create)
label = staticmethod(FormLabel.create)
message = staticmethod(FormMessage.create)
submit = staticmethod(FormSubmit.create)
validity_state = staticmethod(FormValidityState.create)
__call__ = staticmethod(Form.create)
form = Form()
form = FormNamespace()

View File

@ -736,7 +736,97 @@ class FormSubmit(FormComponent):
"""
...
class Form(SimpleNamespace):
class Form(FormRoot):
pass
@overload
@classmethod
def create( # type: ignore
cls,
*children,
reset_on_submit: Optional[Union[Var[bool], bool]] = None,
handle_submit_unique_name: Optional[Union[Var[str], str]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_clear_server_errors: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_leave: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_move: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_out: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_submit: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
) -> "Form":
"""Create a form component.
Args:
*children: The children of the form.
reset_on_submit: If true, the form will be cleared after submit.
handle_submit_unique_name: The name used to make this form's submit handler function unique.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
**props: The properties of the form.
Returns:
The form component.
"""
...
class FormNamespace(SimpleNamespace):
root = staticmethod(FormRoot.create)
control = staticmethod(FormControl.create)
field = staticmethod(FormField.create)
@ -809,7 +899,7 @@ class Form(SimpleNamespace):
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
) -> "FormRoot":
) -> "Form":
"""Create a form component.
Args:
@ -830,4 +920,4 @@ class Form(SimpleNamespace):
"""
...
form = Form()
form = FormNamespace()