forms.py 12 KB

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