Jelajahi Sumber

add default value for text area (#4462)

* add default_value prop in text_area

* also support it for el.textarea
Thomas Brandého 5 bulan lalu
induk
melakukan
c721227a06

+ 3 - 0
reflex/components/el/elements/forms.py

@@ -570,6 +570,9 @@ class Textarea(BaseHTML):
     # Visible width of the text control, in average character widths
     # Visible width of the text control, in average character widths
     cols: Var[Union[str, int, bool]]
     cols: Var[Union[str, int, bool]]
 
 
+    # The default value of the textarea when initially rendered
+    default_value: Var[str]
+
     # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
     # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
     dirname: Var[Union[str, int, bool]]
     dirname: Var[Union[str, int, bool]]
 
 

+ 2 - 0
reflex/components/el/elements/forms.pyi

@@ -1350,6 +1350,7 @@ class Textarea(BaseHTML):
         auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         auto_height: Optional[Union[Var[bool], bool]] = None,
         auto_height: Optional[Union[Var[bool], bool]] = None,
         cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+        default_value: Optional[Union[Var[str], str]] = None,
         dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         enter_key_submit: Optional[Union[Var[bool], bool]] = None,
         enter_key_submit: Optional[Union[Var[bool], bool]] = None,
@@ -1439,6 +1440,7 @@ class Textarea(BaseHTML):
             auto_focus: Automatically focuses the textarea when the page loads
             auto_focus: Automatically focuses the textarea when the page loads
             auto_height: Automatically fit the content height to the text (use min-height with this prop)
             auto_height: Automatically fit the content height to the text (use min-height with this prop)
             cols: Visible width of the text control, in average character widths
             cols: Visible width of the text control, in average character widths
+            default_value: The default value of the textarea when initially rendered
             dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
             dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
             disabled: Disables the textarea
             disabled: Disables the textarea
             enter_key_submit: Enter key submits form (shift-enter adds new line)
             enter_key_submit: Enter key submits form (shift-enter adds new line)

+ 3 - 0
reflex/components/radix/themes/components/text_area.py

@@ -41,6 +41,9 @@ class TextArea(RadixThemesComponent, elements.Textarea):
     # Automatically focuses the textarea when the page loads
     # Automatically focuses the textarea when the page loads
     auto_focus: Var[bool]
     auto_focus: Var[bool]
 
 
+    # The default value of the textarea when initially rendered
+    default_value: Var[str]
+
     # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
     # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
     dirname: Var[str]
     dirname: Var[str]
 
 

+ 2 - 0
reflex/components/radix/themes/components/text_area.pyi

@@ -123,6 +123,7 @@ class TextArea(RadixThemesComponent, elements.Textarea):
         ] = None,
         ] = None,
         auto_complete: Optional[Union[Var[bool], bool]] = None,
         auto_complete: Optional[Union[Var[bool], bool]] = None,
         auto_focus: Optional[Union[Var[bool], bool]] = None,
         auto_focus: Optional[Union[Var[bool], bool]] = None,
+        default_value: Optional[Union[Var[str], str]] = None,
         dirname: Optional[Union[Var[str], str]] = None,
         dirname: Optional[Union[Var[str], str]] = None,
         disabled: Optional[Union[Var[bool], bool]] = None,
         disabled: Optional[Union[Var[bool], bool]] = None,
         form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
         form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
@@ -217,6 +218,7 @@ class TextArea(RadixThemesComponent, elements.Textarea):
             radius: The radius of the text area: "none" | "small" | "medium" | "large" | "full"
             radius: The radius of the text area: "none" | "small" | "medium" | "large" | "full"
             auto_complete: Whether the form control should have autocomplete enabled
             auto_complete: Whether the form control should have autocomplete enabled
             auto_focus: Automatically focuses the textarea when the page loads
             auto_focus: Automatically focuses the textarea when the page loads
+            default_value: The default value of the textarea when initially rendered
             dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
             dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
             disabled: Disables the textarea
             disabled: Disables the textarea
             form: Associates the textarea with a form (by id)
             form: Associates the textarea with a form (by id)