From 6e946631f3bc2b57856c2e4a86bfac9236d1ac82 Mon Sep 17 00:00:00 2001 From: Martin Xu <15661672+martinxu9@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:57:17 -0800 Subject: [PATCH] alias form to form.root (#2579) --- reflex/components/radix/primitives/form.py | 2 +- reflex/components/radix/primitives/form.pyi | 89 ++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/reflex/components/radix/primitives/form.py b/reflex/components/radix/primitives/form.py index 655fd34d5..1b9c93db1 100644 --- a/reflex/components/radix/primitives/form.py +++ b/reflex/components/radix/primitives/form.py @@ -293,11 +293,11 @@ class FormSubmit(FormComponent): class Form(SimpleNamespace): """Form components.""" + root = __call__ = staticmethod(FormRoot.create) control = staticmethod(FormControl.create) field = staticmethod(FormField.create) label = staticmethod(FormLabel.create) message = staticmethod(FormMessage.create) - root = staticmethod(FormRoot.create) submit = staticmethod(FormSubmit.create) validity_state = staticmethod(FormValidityState.create) diff --git a/reflex/components/radix/primitives/form.pyi b/reflex/components/radix/primitives/form.pyi index 5c29918ab..1b549d88f 100644 --- a/reflex/components/radix/primitives/form.pyi +++ b/reflex/components/radix/primitives/form.pyi @@ -753,12 +753,99 @@ class FormSubmit(FormComponent): ... class Form(SimpleNamespace): + root = staticmethod(FormRoot.create) control = staticmethod(FormControl.create) field = staticmethod(FormField.create) label = staticmethod(FormLabel.create) message = staticmethod(FormMessage.create) - root = staticmethod(FormRoot.create) submit = staticmethod(FormSubmit.create) validity_state = staticmethod(FormValidityState.create) + @staticmethod + def __call__( + *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, + _rename_props: Optional[Dict[str, str]] = 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 + ) -> "FormRoot": + """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 + _rename_props: props to change the name of + custom_attrs: custom attribute + **props: The properties of the form. + + Returns: + The form component. + """ + ... + form = Form()