@@ -7,32 +7,85 @@ from typing import Any, Dict, Literal, Optional, Union, overload
7
7
from reflex .vars import Var , BaseVar , ComputedVar
8
8
from reflex .event import EventChain , EventHandler , EventSpec
9
9
from reflex .style import Style
10
- from hashlib import md5
11
- from typing import Any , Dict , Iterator
12
- from jinja2 import Environment
13
10
from reflex .components .chakra import ChakraComponent
14
11
from reflex .components .component import Component
15
- from reflex .components .tags import Tag
16
- from reflex .constants import Dirs , EventTriggers
17
- from reflex .event import EventChain
18
- from reflex .utils import imports
19
- from reflex .utils .format import format_event_chain , to_camel_case
20
- from reflex .vars import BaseVar , Var
12
+ from reflex .components .el .elements .forms import Form as HTMLForm
13
+ from reflex .vars import Var
21
14
22
- FORM_DATA = Var .create ("form_data" )
23
- HANDLE_SUBMIT_JS_JINJA2 = Environment ().from_string (
24
- "\n const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => {\n const $form = ev.target\n ev.preventDefault()\n const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}}\n \n {{ on_submit_event_chain }}\n \n if ({{ reset_on_submit }}) {\n $form.reset()\n }\n })\n "
25
- )
26
-
27
- class Form (ChakraComponent ):
15
+ class Form (ChakraComponent , HTMLForm ):
28
16
@overload
29
17
@classmethod
30
18
def create ( # type: ignore
31
19
cls ,
32
20
* children ,
33
21
as_ : Optional [Union [Var [str ], str ]] = None ,
22
+ accept : Optional [
23
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
24
+ ] = None ,
25
+ accept_charset : Optional [
26
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
27
+ ] = None ,
28
+ action : Optional [
29
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
30
+ ] = None ,
31
+ auto_complete : Optional [
32
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
33
+ ] = None ,
34
+ enc_type : Optional [
35
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
36
+ ] = None ,
37
+ method : Optional [
38
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
39
+ ] = None ,
40
+ name : Optional [Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]] = None ,
41
+ no_validate : Optional [
42
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
43
+ ] = None ,
44
+ target : Optional [
45
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
46
+ ] = None ,
34
47
reset_on_submit : Optional [Union [Var [bool ], bool ]] = None ,
35
48
handle_submit_unique_name : Optional [Union [Var [str ], str ]] = None ,
49
+ access_key : Optional [
50
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
51
+ ] = None ,
52
+ auto_capitalize : Optional [
53
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
54
+ ] = None ,
55
+ content_editable : Optional [
56
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
57
+ ] = None ,
58
+ context_menu : Optional [
59
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
60
+ ] = None ,
61
+ dir : Optional [Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]] = None ,
62
+ draggable : Optional [
63
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
64
+ ] = None ,
65
+ enter_key_hint : Optional [
66
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
67
+ ] = None ,
68
+ hidden : Optional [
69
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
70
+ ] = None ,
71
+ input_mode : Optional [
72
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
73
+ ] = None ,
74
+ item_prop : Optional [
75
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
76
+ ] = None ,
77
+ lang : Optional [Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]] = None ,
78
+ role : Optional [Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]] = None ,
79
+ slot : Optional [Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]] = None ,
80
+ spell_check : Optional [
81
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
82
+ ] = None ,
83
+ tab_index : Optional [
84
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
85
+ ] = None ,
86
+ title : Optional [
87
+ Union [Var [Union [str , int , bool ]], Union [str , int , bool ]]
88
+ ] = None ,
36
89
style : Optional [Style ] = None ,
37
90
key : Optional [Any ] = None ,
38
91
id : Optional [Any ] = None ,
@@ -94,8 +147,33 @@ class Form(ChakraComponent):
94
147
Args:
95
148
*children: The children of the form.
96
149
as_: What the form renders to.
150
+ accept: MIME types the server accepts for file upload
151
+ accept_charset: Character encodings to be used for form submission
152
+ action: URL where the form's data should be submitted
153
+ auto_complete: Whether the form should have autocomplete enabled
154
+ enc_type: Encoding type for the form data when submitted
155
+ method: HTTP method to use for form submission
156
+ name: Name of the form
157
+ no_validate: Indicates that the form should not be validated on submit
158
+ target: Where to display the response after submitting the form
97
159
reset_on_submit: If true, the form will be cleared after submit.
98
- handle_submit_unique_name: The name used to make this form's submit handler function unique
160
+ handle_submit_unique_name: The name used to make this form's submit handler function unique.
161
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
162
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
163
+ content_editable: Indicates whether the element's content is editable.
164
+ context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
165
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
166
+ draggable: Defines whether the element can be dragged.
167
+ enter_key_hint: Hints what media types the media element is able to play.
168
+ hidden: Defines whether the element is hidden.
169
+ input_mode: Defines the type of the element.
170
+ item_prop: Defines the name of the element for metadata purposes.
171
+ lang: Defines the language used in the element.
172
+ role: Defines the role of the element.
173
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
174
+ spell_check: Defines whether the element may be checked for spelling errors.
175
+ tab_index: Defines the position of the current element in the tabbing order.
176
+ title: Defines a tooltip for the element.
99
177
style: The style of the component.
100
178
key: A unique key for the component.
101
179
id: The id for the component.
@@ -108,7 +186,6 @@ class Form(ChakraComponent):
108
186
The form component.
109
187
"""
110
188
...
111
- def get_event_triggers (self ) -> Dict [str , Any ]: ...
112
189
113
190
class FormControl (ChakraComponent ):
114
191
@overload
0 commit comments