From 6387935f0f3f90883db6dc10e4c14f478b632da0 Mon Sep 17 00:00:00 2001 From: Joodith Hermmina Date: Sat, 5 Oct 2024 13:19:21 +0530 Subject: [PATCH 1/2] Include step attribute in input --- .../radix/themes/components/text_field.py | 4 +- .../radix/themes/components/text_field.pyi | 102 +++++++++++++++++- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/reflex/components/radix/themes/components/text_field.py b/reflex/components/radix/themes/components/text_field.py index 6c33729856..3aee9ca602 100644 --- a/reflex/components/radix/themes/components/text_field.py +++ b/reflex/components/radix/themes/components/text_field.py @@ -21,7 +21,7 @@ LiteralTextFieldVariant = Literal["classic", "surface", "soft"] -class TextFieldRoot(elements.Div, RadixThemesComponent): +class TextFieldRoot(elements.Input, RadixThemesComponent): """Captures user input with an optional slot for buttons and icons.""" tag = "TextField.Root" @@ -68,6 +68,8 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): # Specifies the type of input type: Var[str] + step: Var[int] + # Value of the input value: Var[Union[str, int, float]] diff --git a/reflex/components/radix/themes/components/text_field.pyi b/reflex/components/radix/themes/components/text_field.pyi index ff5b79344a..d63b8a9cef 100644 --- a/reflex/components/radix/themes/components/text_field.pyi +++ b/reflex/components/radix/themes/components/text_field.pyi @@ -17,7 +17,7 @@ from ..base import RadixThemesComponent LiteralTextFieldSize = Literal["1", "2", "3"] LiteralTextFieldVariant = Literal["classic", "surface", "soft"] -class TextFieldRoot(elements.Div, RadixThemesComponent): +class TextFieldRoot(elements.Input, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -118,7 +118,32 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, + step: Optional[Union[Var[int], int]] = None, value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + default_checked: Optional[Union[Var[bool], bool]] = None, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_enc_type: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_no_validate: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ Union[Var[Union[bool, int, str]], bool, int, str] @@ -195,12 +220,12 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): Args: *children: The children of the component. - size: Text field size "1" - "3" + size: Specifies the visible width of a text control variant: Variant of text field: "classic" | "surface" | "soft" color_scheme: Override theme color for text field radius: Override theme radius for text field: "none" | "small" | "medium" | "large" | "full" auto_complete: Whether the input should have autocomplete enabled - default_value: The value of the input when initially rendered. + default_value: The initial value for a text field disabled: Disables the input max_length: Specifies the maximum number of characters allowed in the input min_length: Specifies the minimum number of characters required in the input @@ -210,6 +235,27 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): required: Indicates that the input is required type: Specifies the type of input value: Value of the input + accept: Accepted types of files when the input is file type + alt: Alternate text for input type="image" + auto_focus: Automatically focuses the input when the page loads + capture: Captures media from the user (camera or microphone) + checked: Indicates whether the input is checked (for checkboxes and radio buttons) + default_checked: The initial value (for checkboxes and radio buttons) + dirname: Name part of the input to submit in 'dir' and 'name' pair when form is submitted + form: Associates the input with a form (by id) + form_action: URL to send the form data to (for type="submit" buttons) + form_enc_type: How the form data should be encoded when submitting to the server (for type="submit" buttons) + form_method: HTTP method to use for sending form data (for type="submit" buttons) + form_no_validate: Bypasses form validation when submitting (for type="submit" buttons) + form_target: Specifies where to display the response after submitting the form (for type="submit" buttons) + list: References a datalist for suggested options + max: Specifies the maximum value for the input + min: Specifies the minimum value for the input + multiple: Indicates whether multiple values can be entered in an input of the type email or file + pattern: Regex pattern the input's value must match to be valid + src: URL for image inputs + step: Specifies the legal number intervals for an input + use_map: Name of the image map used with the input access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. @@ -472,7 +518,32 @@ class TextField(ComponentNamespace): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, + step: Optional[Union[Var[int], int]] = None, value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + default_checked: Optional[Union[Var[bool], bool]] = None, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_enc_type: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_no_validate: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ Union[Var[Union[bool, int, str]], bool, int, str] @@ -549,12 +620,12 @@ class TextField(ComponentNamespace): Args: *children: The children of the component. - size: Text field size "1" - "3" + size: Specifies the visible width of a text control variant: Variant of text field: "classic" | "surface" | "soft" color_scheme: Override theme color for text field radius: Override theme radius for text field: "none" | "small" | "medium" | "large" | "full" auto_complete: Whether the input should have autocomplete enabled - default_value: The value of the input when initially rendered. + default_value: The initial value for a text field disabled: Disables the input max_length: Specifies the maximum number of characters allowed in the input min_length: Specifies the minimum number of characters required in the input @@ -564,6 +635,27 @@ class TextField(ComponentNamespace): required: Indicates that the input is required type: Specifies the type of input value: Value of the input + accept: Accepted types of files when the input is file type + alt: Alternate text for input type="image" + auto_focus: Automatically focuses the input when the page loads + capture: Captures media from the user (camera or microphone) + checked: Indicates whether the input is checked (for checkboxes and radio buttons) + default_checked: The initial value (for checkboxes and radio buttons) + dirname: Name part of the input to submit in 'dir' and 'name' pair when form is submitted + form: Associates the input with a form (by id) + form_action: URL to send the form data to (for type="submit" buttons) + form_enc_type: How the form data should be encoded when submitting to the server (for type="submit" buttons) + form_method: HTTP method to use for sending form data (for type="submit" buttons) + form_no_validate: Bypasses form validation when submitting (for type="submit" buttons) + form_target: Specifies where to display the response after submitting the form (for type="submit" buttons) + list: References a datalist for suggested options + max: Specifies the maximum value for the input + min: Specifies the minimum value for the input + multiple: Indicates whether multiple values can be entered in an input of the type email or file + pattern: Regex pattern the input's value must match to be valid + src: URL for image inputs + step: Specifies the legal number intervals for an input + use_map: Name of the image map used with the input access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. From 8c9ecbe2f0b964ac05e7319ccf7b1347183818a3 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 12 Dec 2024 04:47:46 -0800 Subject: [PATCH 2/2] Remove `step` prop from TextField it is inherited from Input, and does not need to be redefined --- reflex/components/radix/themes/components/text_field.py | 2 -- reflex/components/radix/themes/components/text_field.pyi | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/reflex/components/radix/themes/components/text_field.py b/reflex/components/radix/themes/components/text_field.py index 3aee9ca602..18f6092299 100644 --- a/reflex/components/radix/themes/components/text_field.py +++ b/reflex/components/radix/themes/components/text_field.py @@ -68,8 +68,6 @@ class TextFieldRoot(elements.Input, RadixThemesComponent): # Specifies the type of input type: Var[str] - step: Var[int] - # Value of the input value: Var[Union[str, int, float]] diff --git a/reflex/components/radix/themes/components/text_field.pyi b/reflex/components/radix/themes/components/text_field.pyi index d63b8a9cef..e33743b1c9 100644 --- a/reflex/components/radix/themes/components/text_field.pyi +++ b/reflex/components/radix/themes/components/text_field.pyi @@ -118,7 +118,6 @@ class TextFieldRoot(elements.Input, RadixThemesComponent): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, - step: Optional[Union[Var[int], int]] = None, value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, @@ -143,6 +142,7 @@ class TextFieldRoot(elements.Input, RadixThemesComponent): multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ @@ -518,7 +518,6 @@ class TextField(ComponentNamespace): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, - step: Optional[Union[Var[int], int]] = None, value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, @@ -543,6 +542,7 @@ class TextField(ComponentNamespace): multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[