forms.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. """Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
  2. from typing import Any, Dict, Optional, Union
  3. from reflex.components.el.element import Element
  4. from reflex.constants.event import EventTriggers
  5. from reflex.vars import Var
  6. from .base import BaseHTML
  7. class Button(BaseHTML):
  8. """Display the button element."""
  9. tag = "button"
  10. # Automatically focuses the button when the page loads
  11. auto_focus: Optional[Var[Union[str, int, bool]]] = None
  12. # Disables the button
  13. disabled: Optional[Var[bool]] = None
  14. # Associates the button with a form (by id)
  15. form: Optional[Var[Union[str, int, bool]]] = None
  16. # URL to send the form data to (for type="submit" buttons)
  17. form_action: Optional[Var[Union[str, int, bool]]] = None
  18. # How the form data should be encoded when submitting to the server (for type="submit" buttons)
  19. form_enc_type: Optional[Var[Union[str, int, bool]]] = None
  20. # HTTP method to use for sending form data (for type="submit" buttons)
  21. form_method: Optional[Var[Union[str, int, bool]]] = None
  22. # Bypasses form validation when submitting (for type="submit" buttons)
  23. form_no_validate: Optional[Var[Union[str, int, bool]]] = None
  24. # Specifies where to display the response after submitting the form (for type="submit" buttons)
  25. form_target: Optional[Var[Union[str, int, bool]]] = None
  26. # Name of the button, used when sending form data
  27. name: Optional[Var[Union[str, int, bool]]] = None
  28. # Type of the button (submit, reset, or button)
  29. type: Optional[Var[Union[str, int, bool]]] = None
  30. # Value of the button, used when sending form data
  31. value: Optional[Var[Union[str, int, bool]]] = None
  32. class Datalist(BaseHTML):
  33. """Display the datalist element."""
  34. tag = "datalist"
  35. # No unique attributes, only common ones are inherited
  36. class Fieldset(Element):
  37. """Display the fieldset element."""
  38. tag = "fieldset"
  39. # Disables all the form control descendants of the fieldset
  40. disabled: Optional[Var[Union[str, int, bool]]] = None
  41. # Associates the fieldset with a form (by id)
  42. form: Optional[Var[Union[str, int, bool]]] = None
  43. # Name of the fieldset, used for scripting
  44. name: Optional[Var[Union[str, int, bool]]] = None
  45. class Form(BaseHTML):
  46. """Display the form element."""
  47. tag = "form"
  48. # MIME types the server accepts for file upload
  49. accept: Optional[Var[Union[str, int, bool]]] = None
  50. # Character encodings to be used for form submission
  51. accept_charset: Optional[Var[Union[str, int, bool]]] = None
  52. # URL where the form's data should be submitted
  53. action: Optional[Var[Union[str, int, bool]]] = None
  54. # Whether the form should have autocomplete enabled
  55. auto_complete: Optional[Var[Union[str, int, bool]]] = None
  56. # Encoding type for the form data when submitted
  57. enc_type: Optional[Var[Union[str, int, bool]]] = None
  58. # HTTP method to use for form submission
  59. method: Optional[Var[Union[str, int, bool]]] = None
  60. # Name of the form
  61. name: Optional[Var[Union[str, int, bool]]] = None
  62. # Indicates that the form should not be validated on submit
  63. no_validate: Optional[Var[Union[str, int, bool]]] = None
  64. # Where to display the response after submitting the form
  65. target: Optional[Var[Union[str, int, bool]]] = None
  66. class Input(BaseHTML):
  67. """Display the input element."""
  68. tag = "input"
  69. # Accepted types of files when the input is file type
  70. accept: Optional[Var[Union[str, int, bool]]] = None
  71. # Alternate text for input type="image"
  72. alt: Optional[Var[Union[str, int, bool]]] = None
  73. # Whether the input should have autocomplete enabled
  74. auto_complete: Optional[Var[Union[str, int, bool]]] = None
  75. # Automatically focuses the input when the page loads
  76. auto_focus: Optional[Var[Union[str, int, bool]]] = None
  77. # Captures media from the user (camera or microphone)
  78. capture: Optional[Var[Union[str, int, bool]]] = None
  79. # Indicates whether the input is checked (for checkboxes and radio buttons)
  80. checked: Optional[Var[Union[str, int, bool]]] = None
  81. # The initial value (for checkboxes and radio buttons)
  82. default_checked: Optional[Var[bool]] = None
  83. # The initial value for a text field
  84. default_value: Optional[Var[str]] = None
  85. # Name part of the input to submit in 'dir' and 'name' pair when form is submitted
  86. dirname: Optional[Var[Union[str, int, bool]]] = None
  87. # Disables the input
  88. disabled: Optional[Var[Union[str, int, bool]]] = None
  89. # Associates the input with a form (by id)
  90. form: Optional[Var[Union[str, int, bool]]] = None
  91. # URL to send the form data to (for type="submit" buttons)
  92. form_action: Optional[Var[Union[str, int, bool]]] = None
  93. # How the form data should be encoded when submitting to the server (for type="submit" buttons)
  94. form_enc_type: Optional[Var[Union[str, int, bool]]] = None
  95. # HTTP method to use for sending form data (for type="submit" buttons)
  96. form_method: Optional[Var[Union[str, int, bool]]] = None
  97. # Bypasses form validation when submitting (for type="submit" buttons)
  98. form_no_validate: Optional[Var[Union[str, int, bool]]] = None
  99. # Specifies where to display the response after submitting the form (for type="submit" buttons)
  100. form_target: Optional[Var[Union[str, int, bool]]] = None
  101. # References a datalist for suggested options
  102. list: Optional[Var[Union[str, int, bool]]] = None
  103. # Specifies the maximum value for the input
  104. max: Optional[Var[Union[str, int, bool]]] = None
  105. # Specifies the maximum number of characters allowed in the input
  106. max_length: Optional[Var[Union[str, int, bool]]] = None
  107. # Specifies the minimum number of characters required in the input
  108. min_length: Optional[Var[Union[str, int, bool]]] = None
  109. # Specifies the minimum value for the input
  110. min: Optional[Var[Union[str, int, bool]]] = None
  111. # Indicates whether multiple values can be entered in an input of the type email or file
  112. multiple: Optional[Var[Union[str, int, bool]]] = None
  113. # Name of the input, used when sending form data
  114. name: Optional[Var[Union[str, int, bool]]] = None
  115. # Regex pattern the input's value must match to be valid
  116. pattern: Optional[Var[Union[str, int, bool]]] = None
  117. # Placeholder text in the input
  118. placeholder: Optional[Var[Union[str, int, bool]]] = None
  119. # Indicates whether the input is read-only
  120. read_only: Optional[Var[Union[str, int, bool]]] = None
  121. # Indicates that the input is required
  122. required: Optional[Var[Union[str, int, bool]]] = None
  123. # Specifies the visible width of a text control
  124. size: Optional[Var[Union[str, int, bool]]] = None
  125. # URL for image inputs
  126. src: Optional[Var[Union[str, int, bool]]] = None
  127. # Specifies the legal number intervals for an input
  128. step: Optional[Var[Union[str, int, bool]]] = None
  129. # Specifies the type of input
  130. type: Optional[Var[Union[str, int, bool]]] = None
  131. # Name of the image map used with the input
  132. use_map: Optional[Var[Union[str, int, bool]]] = None
  133. # Value of the input
  134. value: Optional[Var[Union[str, int, bool]]] = None
  135. def get_event_triggers(self) -> Dict[str, Any]:
  136. """Get the event triggers that pass the component's value to the handler.
  137. Returns:
  138. A dict mapping the event trigger to the var that is passed to the handler.
  139. """
  140. return {
  141. **super().get_event_triggers(),
  142. EventTriggers.ON_CHANGE: lambda e0: [e0.target.value],
  143. EventTriggers.ON_FOCUS: lambda e0: [e0.target.value],
  144. EventTriggers.ON_BLUR: lambda e0: [e0.target.value],
  145. EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key],
  146. EventTriggers.ON_KEY_UP: lambda e0: [e0.key],
  147. }
  148. class Label(BaseHTML):
  149. """Display the label element."""
  150. tag = "label"
  151. # ID of a form control with which the label is associated
  152. html_for: Optional[Var[Union[str, int, bool]]] = None
  153. # Associates the label with a form (by id)
  154. form: Optional[Var[Union[str, int, bool]]] = None
  155. class Legend(BaseHTML):
  156. """Display the legend element."""
  157. tag = "legend"
  158. # No unique attributes, only common ones are inherited
  159. class Meter(BaseHTML):
  160. """Display the meter element."""
  161. tag = "meter"
  162. # Associates the meter with a form (by id)
  163. form: Optional[Var[Union[str, int, bool]]] = None
  164. # High limit of range (above this is considered high value)
  165. high: Optional[Var[Union[str, int, bool]]] = None
  166. # Low limit of range (below this is considered low value)
  167. low: Optional[Var[Union[str, int, bool]]] = None
  168. # Maximum value of the range
  169. max: Optional[Var[Union[str, int, bool]]] = None
  170. # Minimum value of the range
  171. min: Optional[Var[Union[str, int, bool]]] = None
  172. # Optimum value in the range
  173. optimum: Optional[Var[Union[str, int, bool]]] = None
  174. # Current value of the meter
  175. value: Optional[Var[Union[str, int, bool]]] = None
  176. class Optgroup(BaseHTML):
  177. """Display the optgroup element."""
  178. tag = "optgroup"
  179. # Disables the optgroup
  180. disabled: Optional[Var[Union[str, int, bool]]] = None
  181. # Label for the optgroup
  182. label: Optional[Var[Union[str, int, bool]]] = None
  183. class Option(BaseHTML):
  184. """Display the option element."""
  185. tag = "option"
  186. # Disables the option
  187. disabled: Optional[Var[Union[str, int, bool]]] = None
  188. # Label for the option, if the text is not the label
  189. label: Optional[Var[Union[str, int, bool]]] = None
  190. # Indicates that the option is initially selected
  191. selected: Optional[Var[Union[str, int, bool]]] = None
  192. # Value to be sent as form data
  193. value: Optional[Var[Union[str, int, bool]]] = None
  194. class Output(BaseHTML):
  195. """Display the output element."""
  196. tag = "output"
  197. # Associates the output with one or more elements (by their IDs)
  198. html_for: Optional[Var[Union[str, int, bool]]] = None
  199. # Associates the output with a form (by id)
  200. form: Optional[Var[Union[str, int, bool]]] = None
  201. # Name of the output element for form submission
  202. name: Optional[Var[Union[str, int, bool]]] = None
  203. class Progress(BaseHTML):
  204. """Display the progress element."""
  205. tag = "progress"
  206. # Associates the progress element with a form (by id)
  207. form: Optional[Var[Union[str, int, bool]]] = None
  208. # Maximum value of the progress indicator
  209. max: Optional[Var[Union[str, int, bool]]] = None
  210. # Current value of the progress indicator
  211. value: Optional[Var[Union[str, int, bool]]] = None
  212. class Select(BaseHTML):
  213. """Display the select element."""
  214. tag = "select"
  215. # Whether the form control should have autocomplete enabled
  216. auto_complete: Optional[Var[Union[str, int, bool]]] = None
  217. # Automatically focuses the select when the page loads
  218. auto_focus: Optional[Var[Union[str, int, bool]]] = None
  219. # Disables the select control
  220. disabled: Optional[Var[Union[str, int, bool]]] = None
  221. # Associates the select with a form (by id)
  222. form: Optional[Var[Union[str, int, bool]]] = None
  223. # Indicates that multiple options can be selected
  224. multiple: Optional[Var[Union[str, int, bool]]] = None
  225. # Name of the select, used when submitting the form
  226. name: Optional[Var[Union[str, int, bool]]] = None
  227. # Indicates that the select control must have a selected option
  228. required: Optional[Var[Union[str, int, bool]]] = None
  229. # Number of visible options in a drop-down list
  230. size: Optional[Var[Union[str, int, bool]]] = None
  231. def get_event_triggers(self) -> Dict[str, Any]:
  232. """Get the event triggers that pass the component's value to the handler.
  233. Returns:
  234. A dict mapping the event trigger to the var that is passed to the handler.
  235. """
  236. return {
  237. **super().get_event_triggers(),
  238. EventTriggers.ON_CHANGE: lambda e0: [e0.target.value],
  239. }
  240. class Textarea(BaseHTML):
  241. """Display the textarea element."""
  242. tag = "textarea"
  243. # Whether the form control should have autocomplete enabled
  244. auto_complete: Optional[Var[Union[str, int, bool]]] = None
  245. # Automatically focuses the textarea when the page loads
  246. auto_focus: Optional[Var[Union[str, int, bool]]] = None
  247. # Visible width of the text control, in average character widths
  248. cols: Optional[Var[Union[str, int, bool]]] = None
  249. # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
  250. dirname: Optional[Var[Union[str, int, bool]]] = None
  251. # Disables the textarea
  252. disabled: Optional[Var[Union[str, int, bool]]] = None
  253. # Associates the textarea with a form (by id)
  254. form: Optional[Var[Union[str, int, bool]]] = None
  255. # Maximum number of characters allowed in the textarea
  256. max_length: Optional[Var[Union[str, int, bool]]] = None
  257. # Minimum number of characters required in the textarea
  258. min_length: Optional[Var[Union[str, int, bool]]] = None
  259. # Name of the textarea, used when submitting the form
  260. name: Optional[Var[Union[str, int, bool]]] = None
  261. # Placeholder text in the textarea
  262. placeholder: Optional[Var[Union[str, int, bool]]] = None
  263. # Indicates whether the textarea is read-only
  264. read_only: Optional[Var[Union[str, int, bool]]] = None
  265. # Indicates that the textarea is required
  266. required: Optional[Var[Union[str, int, bool]]] = None
  267. # Visible number of lines in the text control
  268. rows: Optional[Var[Union[str, int, bool]]] = None
  269. # The controlled value of the textarea, read only unless used with on_change
  270. value: Optional[Var[Union[str, int, bool]]] = None
  271. # How the text in the textarea is to be wrapped when submitting the form
  272. wrap: Optional[Var[Union[str, int, bool]]] = None
  273. def get_event_triggers(self) -> Dict[str, Any]:
  274. """Get the event triggers that pass the component's value to the handler.
  275. Returns:
  276. A dict mapping the event trigger to the var that is passed to the handler.
  277. """
  278. return {
  279. **super().get_event_triggers(),
  280. EventTriggers.ON_CHANGE: lambda e0: [e0.target.value],
  281. EventTriggers.ON_FOCUS: lambda e0: [e0.target.value],
  282. EventTriggers.ON_BLUR: lambda e0: [e0.target.value],
  283. EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key],
  284. EventTriggers.ON_KEY_UP: lambda e0: [e0.key],
  285. }