form.pyi 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. """Stub file for reflex/components/forms/form.py"""
  2. # ------------------- DO NOT EDIT ----------------------
  3. # This file was generated by `scripts/pyi_generator.py`!
  4. # ------------------------------------------------------
  5. from typing import Any, Dict, Literal, Optional, Union, overload
  6. from reflex.vars import Var, BaseVar, ComputedVar
  7. from reflex.event import EventChain, EventHandler, EventSpec
  8. from reflex.style import Style
  9. from hashlib import md5
  10. from typing import Any, Dict, Iterator
  11. from jinja2 import Environment
  12. from reflex.components.component import Component
  13. from reflex.components.libs.chakra import ChakraComponent
  14. from reflex.components.tags import Tag
  15. from reflex.constants import Dirs, EventTriggers
  16. from reflex.event import EventChain
  17. from reflex.utils import imports
  18. from reflex.utils.format import format_event_chain, to_camel_case
  19. from reflex.vars import BaseVar, Var
  20. FORM_DATA = Var.create("form_data")
  21. HANDLE_SUBMIT_JS_JINJA2 = Environment().from_string(
  22. "\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 "
  23. )
  24. class Form(ChakraComponent):
  25. @overload
  26. @classmethod
  27. def create( # type: ignore
  28. cls,
  29. *children,
  30. as_: Optional[Union[Var[str], str]] = None,
  31. reset_on_submit: Optional[Union[Var[bool], bool]] = None,
  32. handle_submit_unique_name: Optional[Union[Var[str], str]] = None,
  33. style: Optional[Style] = None,
  34. key: Optional[Any] = None,
  35. id: Optional[Any] = None,
  36. class_name: Optional[Any] = None,
  37. autofocus: Optional[bool] = None,
  38. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  39. on_blur: Optional[
  40. Union[EventHandler, EventSpec, list, function, BaseVar]
  41. ] = None,
  42. on_click: Optional[
  43. Union[EventHandler, EventSpec, list, function, BaseVar]
  44. ] = None,
  45. on_context_menu: Optional[
  46. Union[EventHandler, EventSpec, list, function, BaseVar]
  47. ] = None,
  48. on_double_click: Optional[
  49. Union[EventHandler, EventSpec, list, function, BaseVar]
  50. ] = None,
  51. on_focus: Optional[
  52. Union[EventHandler, EventSpec, list, function, BaseVar]
  53. ] = None,
  54. on_mount: Optional[
  55. Union[EventHandler, EventSpec, list, function, BaseVar]
  56. ] = None,
  57. on_mouse_down: Optional[
  58. Union[EventHandler, EventSpec, list, function, BaseVar]
  59. ] = None,
  60. on_mouse_enter: Optional[
  61. Union[EventHandler, EventSpec, list, function, BaseVar]
  62. ] = None,
  63. on_mouse_leave: Optional[
  64. Union[EventHandler, EventSpec, list, function, BaseVar]
  65. ] = None,
  66. on_mouse_move: Optional[
  67. Union[EventHandler, EventSpec, list, function, BaseVar]
  68. ] = None,
  69. on_mouse_out: Optional[
  70. Union[EventHandler, EventSpec, list, function, BaseVar]
  71. ] = None,
  72. on_mouse_over: Optional[
  73. Union[EventHandler, EventSpec, list, function, BaseVar]
  74. ] = None,
  75. on_mouse_up: Optional[
  76. Union[EventHandler, EventSpec, list, function, BaseVar]
  77. ] = None,
  78. on_scroll: Optional[
  79. Union[EventHandler, EventSpec, list, function, BaseVar]
  80. ] = None,
  81. on_submit: Optional[
  82. Union[EventHandler, EventSpec, list, function, BaseVar]
  83. ] = None,
  84. on_unmount: Optional[
  85. Union[EventHandler, EventSpec, list, function, BaseVar]
  86. ] = None,
  87. **props
  88. ) -> "Form":
  89. """Create a form component.
  90. Args:
  91. *children: The children of the form.
  92. as_: What the form renders to.
  93. reset_on_submit: If true, the form will be cleared after submit.
  94. handle_submit_unique_name: The name used to make this form's submit handler function unique
  95. style: The style of the component.
  96. key: A unique key for the component.
  97. id: The id for the component.
  98. class_name: The class name for the component.
  99. autofocus: Whether the component should take the focus once the page is loaded
  100. custom_attrs: custom attribute
  101. **props: The properties of the form.
  102. Returns:
  103. The form component.
  104. """
  105. ...
  106. def get_event_triggers(self) -> Dict[str, Any]: ...
  107. class FormControl(ChakraComponent):
  108. @overload
  109. @classmethod
  110. def create( # type: ignore
  111. cls,
  112. *children,
  113. label=None,
  114. input=None,
  115. help_text=None,
  116. error_message=None,
  117. is_disabled: Optional[Union[Var[bool], bool]] = None,
  118. is_invalid: Optional[Union[Var[bool], bool]] = None,
  119. is_read_only: Optional[Union[Var[bool], bool]] = None,
  120. is_required: Optional[Union[Var[bool], bool]] = None,
  121. style: Optional[Style] = None,
  122. key: Optional[Any] = None,
  123. id: Optional[Any] = None,
  124. class_name: Optional[Any] = None,
  125. autofocus: Optional[bool] = None,
  126. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  127. on_blur: Optional[
  128. Union[EventHandler, EventSpec, list, function, BaseVar]
  129. ] = None,
  130. on_click: Optional[
  131. Union[EventHandler, EventSpec, list, function, BaseVar]
  132. ] = None,
  133. on_context_menu: Optional[
  134. Union[EventHandler, EventSpec, list, function, BaseVar]
  135. ] = None,
  136. on_double_click: Optional[
  137. Union[EventHandler, EventSpec, list, function, BaseVar]
  138. ] = None,
  139. on_focus: Optional[
  140. Union[EventHandler, EventSpec, list, function, BaseVar]
  141. ] = None,
  142. on_mount: Optional[
  143. Union[EventHandler, EventSpec, list, function, BaseVar]
  144. ] = None,
  145. on_mouse_down: Optional[
  146. Union[EventHandler, EventSpec, list, function, BaseVar]
  147. ] = None,
  148. on_mouse_enter: Optional[
  149. Union[EventHandler, EventSpec, list, function, BaseVar]
  150. ] = None,
  151. on_mouse_leave: Optional[
  152. Union[EventHandler, EventSpec, list, function, BaseVar]
  153. ] = None,
  154. on_mouse_move: Optional[
  155. Union[EventHandler, EventSpec, list, function, BaseVar]
  156. ] = None,
  157. on_mouse_out: Optional[
  158. Union[EventHandler, EventSpec, list, function, BaseVar]
  159. ] = None,
  160. on_mouse_over: Optional[
  161. Union[EventHandler, EventSpec, list, function, BaseVar]
  162. ] = None,
  163. on_mouse_up: Optional[
  164. Union[EventHandler, EventSpec, list, function, BaseVar]
  165. ] = None,
  166. on_scroll: Optional[
  167. Union[EventHandler, EventSpec, list, function, BaseVar]
  168. ] = None,
  169. on_unmount: Optional[
  170. Union[EventHandler, EventSpec, list, function, BaseVar]
  171. ] = None,
  172. **props
  173. ) -> "FormControl":
  174. """Create a form control component.
  175. Args:
  176. *children: The children of the form control.
  177. label: The label of the form control.
  178. input: The input of the form control.
  179. help_text: The help text of the form control.
  180. error_message: The error message of the form control.
  181. is_disabled: If true, the form control will be disabled.
  182. is_invalid: If true, the form control will be invalid.
  183. is_read_only: If true, the form control will be readonly
  184. is_required: If true, the form control will be required.
  185. style: The style of the component.
  186. key: A unique key for the component.
  187. id: The id for the component.
  188. class_name: The class name for the component.
  189. autofocus: Whether the component should take the focus once the page is loaded
  190. custom_attrs: custom attribute
  191. **props: The properties of the form control.
  192. Raises:
  193. AttributeError: raise an error if missing required kwargs.
  194. Returns:
  195. The form control component.
  196. """
  197. ...
  198. class FormHelperText(ChakraComponent):
  199. @overload
  200. @classmethod
  201. def create( # type: ignore
  202. cls,
  203. *children,
  204. style: Optional[Style] = None,
  205. key: Optional[Any] = None,
  206. id: Optional[Any] = None,
  207. class_name: Optional[Any] = None,
  208. autofocus: Optional[bool] = None,
  209. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  210. on_blur: Optional[
  211. Union[EventHandler, EventSpec, list, function, BaseVar]
  212. ] = None,
  213. on_click: Optional[
  214. Union[EventHandler, EventSpec, list, function, BaseVar]
  215. ] = None,
  216. on_context_menu: Optional[
  217. Union[EventHandler, EventSpec, list, function, BaseVar]
  218. ] = None,
  219. on_double_click: Optional[
  220. Union[EventHandler, EventSpec, list, function, BaseVar]
  221. ] = None,
  222. on_focus: Optional[
  223. Union[EventHandler, EventSpec, list, function, BaseVar]
  224. ] = None,
  225. on_mount: Optional[
  226. Union[EventHandler, EventSpec, list, function, BaseVar]
  227. ] = None,
  228. on_mouse_down: Optional[
  229. Union[EventHandler, EventSpec, list, function, BaseVar]
  230. ] = None,
  231. on_mouse_enter: Optional[
  232. Union[EventHandler, EventSpec, list, function, BaseVar]
  233. ] = None,
  234. on_mouse_leave: Optional[
  235. Union[EventHandler, EventSpec, list, function, BaseVar]
  236. ] = None,
  237. on_mouse_move: Optional[
  238. Union[EventHandler, EventSpec, list, function, BaseVar]
  239. ] = None,
  240. on_mouse_out: Optional[
  241. Union[EventHandler, EventSpec, list, function, BaseVar]
  242. ] = None,
  243. on_mouse_over: Optional[
  244. Union[EventHandler, EventSpec, list, function, BaseVar]
  245. ] = None,
  246. on_mouse_up: Optional[
  247. Union[EventHandler, EventSpec, list, function, BaseVar]
  248. ] = None,
  249. on_scroll: Optional[
  250. Union[EventHandler, EventSpec, list, function, BaseVar]
  251. ] = None,
  252. on_unmount: Optional[
  253. Union[EventHandler, EventSpec, list, function, BaseVar]
  254. ] = None,
  255. **props
  256. ) -> "FormHelperText":
  257. """Create the component.
  258. Args:
  259. *children: The children of the component.
  260. style: The style of the component.
  261. key: A unique key for the component.
  262. id: The id for the component.
  263. class_name: The class name for the component.
  264. autofocus: Whether the component should take the focus once the page is loaded
  265. custom_attrs: custom attribute
  266. **props: The props of the component.
  267. Returns:
  268. The component.
  269. Raises:
  270. TypeError: If an invalid child is passed.
  271. """
  272. ...
  273. class FormLabel(ChakraComponent):
  274. @overload
  275. @classmethod
  276. def create( # type: ignore
  277. cls,
  278. *children,
  279. html_for: Optional[Union[Var[str], str]] = None,
  280. style: Optional[Style] = None,
  281. key: Optional[Any] = None,
  282. id: Optional[Any] = None,
  283. class_name: Optional[Any] = None,
  284. autofocus: Optional[bool] = None,
  285. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  286. on_blur: Optional[
  287. Union[EventHandler, EventSpec, list, function, BaseVar]
  288. ] = None,
  289. on_click: Optional[
  290. Union[EventHandler, EventSpec, list, function, BaseVar]
  291. ] = None,
  292. on_context_menu: Optional[
  293. Union[EventHandler, EventSpec, list, function, BaseVar]
  294. ] = None,
  295. on_double_click: Optional[
  296. Union[EventHandler, EventSpec, list, function, BaseVar]
  297. ] = None,
  298. on_focus: Optional[
  299. Union[EventHandler, EventSpec, list, function, BaseVar]
  300. ] = None,
  301. on_mount: Optional[
  302. Union[EventHandler, EventSpec, list, function, BaseVar]
  303. ] = None,
  304. on_mouse_down: Optional[
  305. Union[EventHandler, EventSpec, list, function, BaseVar]
  306. ] = None,
  307. on_mouse_enter: Optional[
  308. Union[EventHandler, EventSpec, list, function, BaseVar]
  309. ] = None,
  310. on_mouse_leave: Optional[
  311. Union[EventHandler, EventSpec, list, function, BaseVar]
  312. ] = None,
  313. on_mouse_move: Optional[
  314. Union[EventHandler, EventSpec, list, function, BaseVar]
  315. ] = None,
  316. on_mouse_out: Optional[
  317. Union[EventHandler, EventSpec, list, function, BaseVar]
  318. ] = None,
  319. on_mouse_over: Optional[
  320. Union[EventHandler, EventSpec, list, function, BaseVar]
  321. ] = None,
  322. on_mouse_up: Optional[
  323. Union[EventHandler, EventSpec, list, function, BaseVar]
  324. ] = None,
  325. on_scroll: Optional[
  326. Union[EventHandler, EventSpec, list, function, BaseVar]
  327. ] = None,
  328. on_unmount: Optional[
  329. Union[EventHandler, EventSpec, list, function, BaseVar]
  330. ] = None,
  331. **props
  332. ) -> "FormLabel":
  333. """Create the component.
  334. Args:
  335. *children: The children of the component.
  336. html_for: Link
  337. style: The style of the component.
  338. key: A unique key for the component.
  339. id: The id for the component.
  340. class_name: The class name for the component.
  341. autofocus: Whether the component should take the focus once the page is loaded
  342. custom_attrs: custom attribute
  343. **props: The props of the component.
  344. Returns:
  345. The component.
  346. Raises:
  347. TypeError: If an invalid child is passed.
  348. """
  349. ...
  350. class FormErrorMessage(ChakraComponent):
  351. @overload
  352. @classmethod
  353. def create( # type: ignore
  354. cls,
  355. *children,
  356. style: Optional[Style] = None,
  357. key: Optional[Any] = None,
  358. id: Optional[Any] = None,
  359. class_name: Optional[Any] = None,
  360. autofocus: Optional[bool] = None,
  361. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  362. on_blur: Optional[
  363. Union[EventHandler, EventSpec, list, function, BaseVar]
  364. ] = None,
  365. on_click: Optional[
  366. Union[EventHandler, EventSpec, list, function, BaseVar]
  367. ] = None,
  368. on_context_menu: Optional[
  369. Union[EventHandler, EventSpec, list, function, BaseVar]
  370. ] = None,
  371. on_double_click: Optional[
  372. Union[EventHandler, EventSpec, list, function, BaseVar]
  373. ] = None,
  374. on_focus: Optional[
  375. Union[EventHandler, EventSpec, list, function, BaseVar]
  376. ] = None,
  377. on_mount: Optional[
  378. Union[EventHandler, EventSpec, list, function, BaseVar]
  379. ] = None,
  380. on_mouse_down: Optional[
  381. Union[EventHandler, EventSpec, list, function, BaseVar]
  382. ] = None,
  383. on_mouse_enter: Optional[
  384. Union[EventHandler, EventSpec, list, function, BaseVar]
  385. ] = None,
  386. on_mouse_leave: Optional[
  387. Union[EventHandler, EventSpec, list, function, BaseVar]
  388. ] = None,
  389. on_mouse_move: Optional[
  390. Union[EventHandler, EventSpec, list, function, BaseVar]
  391. ] = None,
  392. on_mouse_out: Optional[
  393. Union[EventHandler, EventSpec, list, function, BaseVar]
  394. ] = None,
  395. on_mouse_over: Optional[
  396. Union[EventHandler, EventSpec, list, function, BaseVar]
  397. ] = None,
  398. on_mouse_up: Optional[
  399. Union[EventHandler, EventSpec, list, function, BaseVar]
  400. ] = None,
  401. on_scroll: Optional[
  402. Union[EventHandler, EventSpec, list, function, BaseVar]
  403. ] = None,
  404. on_unmount: Optional[
  405. Union[EventHandler, EventSpec, list, function, BaseVar]
  406. ] = None,
  407. **props
  408. ) -> "FormErrorMessage":
  409. """Create the component.
  410. Args:
  411. *children: The children of the component.
  412. style: The style of the component.
  413. key: A unique key for the component.
  414. id: The id for the component.
  415. class_name: The class name for the component.
  416. autofocus: Whether the component should take the focus once the page is loaded
  417. custom_attrs: custom attribute
  418. **props: The props of the component.
  419. Returns:
  420. The component.
  421. Raises:
  422. TypeError: If an invalid child is passed.
  423. """
  424. ...