upload.pyi 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. """Stub file for reflex/components/core/upload.py"""
  2. # ------------------- DO NOT EDIT ----------------------
  3. # This file was generated by `reflex/utils/pyi_generator.py`!
  4. # ------------------------------------------------------
  5. from pathlib import Path
  6. from typing import Any, Callable, ClassVar, Dict, List, Optional, Union, overload
  7. from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
  8. from reflex.constants import Dirs
  9. from reflex.event import (
  10. CallableEventSpec,
  11. EventHandler,
  12. EventSpec,
  13. )
  14. from reflex.ivars.base import ImmutableCallableVar, ImmutableVar
  15. from reflex.style import Style
  16. from reflex.utils.imports import ImportVar
  17. from reflex.vars import Var, VarData
  18. DEFAULT_UPLOAD_ID: str
  19. upload_files_context_var_data: VarData
  20. @ImmutableCallableVar
  21. def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: ...
  22. @ImmutableCallableVar
  23. def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> ImmutableVar: ...
  24. @CallableEventSpec
  25. def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ...
  26. def cancel_upload(upload_id: str) -> EventSpec: ...
  27. def get_upload_dir() -> Path: ...
  28. uploaded_files_url_prefix = ImmutableVar(
  29. _var_name="getBackendURL(env.UPLOAD)",
  30. _var_data=VarData(
  31. imports={
  32. f"/{Dirs.STATE_PATH}": "getBackendURL",
  33. "/env.json": ImportVar(tag="env", is_default=True),
  34. }
  35. ),
  36. ).to(str)
  37. def get_upload_url(file_path: str) -> Var[str]: ...
  38. class UploadFilesProvider(Component):
  39. @overload
  40. @classmethod
  41. def create( # type: ignore
  42. cls,
  43. *children,
  44. style: Optional[Style] = None,
  45. key: Optional[Any] = None,
  46. id: Optional[Any] = None,
  47. class_name: Optional[Any] = None,
  48. autofocus: Optional[bool] = None,
  49. custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
  50. on_blur: Optional[
  51. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  52. ] = None,
  53. on_click: Optional[
  54. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  55. ] = None,
  56. on_context_menu: Optional[
  57. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  58. ] = None,
  59. on_double_click: Optional[
  60. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  61. ] = None,
  62. on_focus: Optional[
  63. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  64. ] = None,
  65. on_mount: Optional[
  66. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  67. ] = None,
  68. on_mouse_down: Optional[
  69. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  70. ] = None,
  71. on_mouse_enter: Optional[
  72. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  73. ] = None,
  74. on_mouse_leave: Optional[
  75. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  76. ] = None,
  77. on_mouse_move: Optional[
  78. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  79. ] = None,
  80. on_mouse_out: Optional[
  81. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  82. ] = None,
  83. on_mouse_over: Optional[
  84. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  85. ] = None,
  86. on_mouse_up: Optional[
  87. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  88. ] = None,
  89. on_scroll: Optional[
  90. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  91. ] = None,
  92. on_unmount: Optional[
  93. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  94. ] = None,
  95. **props,
  96. ) -> "UploadFilesProvider":
  97. """Create the component.
  98. Args:
  99. *children: The children of the component.
  100. style: The style of the component.
  101. key: A unique key for the component.
  102. id: The id for the component.
  103. class_name: The class name for the component.
  104. autofocus: Whether the component should take the focus once the page is loaded
  105. custom_attrs: custom attribute
  106. **props: The props of the component.
  107. Returns:
  108. The component.
  109. """
  110. ...
  111. class Upload(MemoizationLeaf):
  112. is_used: ClassVar[bool] = False
  113. @overload
  114. @classmethod
  115. def create( # type: ignore
  116. cls,
  117. *children,
  118. accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None,
  119. disabled: Optional[Union[Var[bool], bool]] = None,
  120. max_files: Optional[Union[Var[int], int]] = None,
  121. max_size: Optional[Union[Var[int], int]] = None,
  122. min_size: Optional[Union[Var[int], int]] = None,
  123. multiple: Optional[Union[Var[bool], bool]] = None,
  124. no_click: Optional[Union[Var[bool], bool]] = None,
  125. no_drag: Optional[Union[Var[bool], bool]] = None,
  126. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  127. style: Optional[Style] = None,
  128. key: Optional[Any] = None,
  129. id: Optional[Any] = None,
  130. class_name: Optional[Any] = None,
  131. autofocus: Optional[bool] = None,
  132. custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
  133. on_blur: Optional[
  134. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  135. ] = None,
  136. on_click: Optional[
  137. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  138. ] = None,
  139. on_context_menu: Optional[
  140. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  141. ] = None,
  142. on_double_click: Optional[
  143. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  144. ] = None,
  145. on_drop: Optional[
  146. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  147. ] = None,
  148. on_focus: Optional[
  149. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  150. ] = None,
  151. on_mount: Optional[
  152. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  153. ] = None,
  154. on_mouse_down: Optional[
  155. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  156. ] = None,
  157. on_mouse_enter: Optional[
  158. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  159. ] = None,
  160. on_mouse_leave: Optional[
  161. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  162. ] = None,
  163. on_mouse_move: Optional[
  164. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  165. ] = None,
  166. on_mouse_out: Optional[
  167. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  168. ] = None,
  169. on_mouse_over: Optional[
  170. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  171. ] = None,
  172. on_mouse_up: Optional[
  173. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  174. ] = None,
  175. on_scroll: Optional[
  176. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  177. ] = None,
  178. on_unmount: Optional[
  179. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  180. ] = None,
  181. **props,
  182. ) -> "Upload":
  183. """Create an upload component.
  184. Args:
  185. *children: The children of the component.
  186. accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
  187. disabled: Whether the dropzone is disabled.
  188. max_files: The maximum number of files that can be uploaded.
  189. max_size: The maximum file size (bytes) that can be uploaded.
  190. min_size: The minimum file size (bytes) that can be uploaded.
  191. multiple: Whether to allow multiple files to be uploaded.
  192. no_click: Whether to disable click to upload.
  193. no_drag: Whether to disable drag and drop.
  194. no_keyboard: Whether to disable using the space/enter keys to upload.
  195. style: The style of the component.
  196. key: A unique key for the component.
  197. id: The id for the component.
  198. class_name: The class name for the component.
  199. autofocus: Whether the component should take the focus once the page is loaded
  200. custom_attrs: custom attribute
  201. **props: The properties of the component.
  202. Returns:
  203. The upload component.
  204. """
  205. ...
  206. class StyledUpload(Upload):
  207. @overload
  208. @classmethod
  209. def create( # type: ignore
  210. cls,
  211. *children,
  212. accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None,
  213. disabled: Optional[Union[Var[bool], bool]] = None,
  214. max_files: Optional[Union[Var[int], int]] = None,
  215. max_size: Optional[Union[Var[int], int]] = None,
  216. min_size: Optional[Union[Var[int], int]] = None,
  217. multiple: Optional[Union[Var[bool], bool]] = None,
  218. no_click: Optional[Union[Var[bool], bool]] = None,
  219. no_drag: Optional[Union[Var[bool], bool]] = None,
  220. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  221. style: Optional[Style] = None,
  222. key: Optional[Any] = None,
  223. id: Optional[Any] = None,
  224. class_name: Optional[Any] = None,
  225. autofocus: Optional[bool] = None,
  226. custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
  227. on_blur: Optional[
  228. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  229. ] = None,
  230. on_click: Optional[
  231. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  232. ] = None,
  233. on_context_menu: Optional[
  234. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  235. ] = None,
  236. on_double_click: Optional[
  237. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  238. ] = None,
  239. on_drop: Optional[
  240. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  241. ] = None,
  242. on_focus: Optional[
  243. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  244. ] = None,
  245. on_mount: Optional[
  246. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  247. ] = None,
  248. on_mouse_down: Optional[
  249. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  250. ] = None,
  251. on_mouse_enter: Optional[
  252. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  253. ] = None,
  254. on_mouse_leave: Optional[
  255. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  256. ] = None,
  257. on_mouse_move: Optional[
  258. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  259. ] = None,
  260. on_mouse_out: Optional[
  261. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  262. ] = None,
  263. on_mouse_over: Optional[
  264. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  265. ] = None,
  266. on_mouse_up: Optional[
  267. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  268. ] = None,
  269. on_scroll: Optional[
  270. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  271. ] = None,
  272. on_unmount: Optional[
  273. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  274. ] = None,
  275. **props,
  276. ) -> "StyledUpload":
  277. """Create the styled upload component.
  278. Args:
  279. *children: The children of the component.
  280. accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
  281. disabled: Whether the dropzone is disabled.
  282. max_files: The maximum number of files that can be uploaded.
  283. max_size: The maximum file size (bytes) that can be uploaded.
  284. min_size: The minimum file size (bytes) that can be uploaded.
  285. multiple: Whether to allow multiple files to be uploaded.
  286. no_click: Whether to disable click to upload.
  287. no_drag: Whether to disable drag and drop.
  288. no_keyboard: Whether to disable using the space/enter keys to upload.
  289. style: The style of the component.
  290. key: A unique key for the component.
  291. id: The id for the component.
  292. class_name: The class name for the component.
  293. autofocus: Whether the component should take the focus once the page is loaded
  294. custom_attrs: custom attribute
  295. **props: The properties of the component.
  296. Returns:
  297. The styled upload component.
  298. """
  299. ...
  300. class UploadNamespace(ComponentNamespace):
  301. root = Upload.create
  302. @staticmethod
  303. def __call__(
  304. *children,
  305. accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None,
  306. disabled: Optional[Union[Var[bool], bool]] = None,
  307. max_files: Optional[Union[Var[int], int]] = None,
  308. max_size: Optional[Union[Var[int], int]] = None,
  309. min_size: Optional[Union[Var[int], int]] = None,
  310. multiple: Optional[Union[Var[bool], bool]] = None,
  311. no_click: Optional[Union[Var[bool], bool]] = None,
  312. no_drag: Optional[Union[Var[bool], bool]] = None,
  313. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  314. style: Optional[Style] = None,
  315. key: Optional[Any] = None,
  316. id: Optional[Any] = None,
  317. class_name: Optional[Any] = None,
  318. autofocus: Optional[bool] = None,
  319. custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
  320. on_blur: Optional[
  321. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  322. ] = None,
  323. on_click: Optional[
  324. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  325. ] = None,
  326. on_context_menu: Optional[
  327. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  328. ] = None,
  329. on_double_click: Optional[
  330. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  331. ] = None,
  332. on_drop: Optional[
  333. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  334. ] = None,
  335. on_focus: Optional[
  336. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  337. ] = None,
  338. on_mount: Optional[
  339. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  340. ] = None,
  341. on_mouse_down: Optional[
  342. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  343. ] = None,
  344. on_mouse_enter: Optional[
  345. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  346. ] = None,
  347. on_mouse_leave: Optional[
  348. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  349. ] = None,
  350. on_mouse_move: Optional[
  351. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  352. ] = None,
  353. on_mouse_out: Optional[
  354. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  355. ] = None,
  356. on_mouse_over: Optional[
  357. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  358. ] = None,
  359. on_mouse_up: Optional[
  360. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  361. ] = None,
  362. on_scroll: Optional[
  363. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  364. ] = None,
  365. on_unmount: Optional[
  366. Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
  367. ] = None,
  368. **props,
  369. ) -> "StyledUpload":
  370. """Create the styled upload component.
  371. Args:
  372. *children: The children of the component.
  373. accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
  374. disabled: Whether the dropzone is disabled.
  375. max_files: The maximum number of files that can be uploaded.
  376. max_size: The maximum file size (bytes) that can be uploaded.
  377. min_size: The minimum file size (bytes) that can be uploaded.
  378. multiple: Whether to allow multiple files to be uploaded.
  379. no_click: Whether to disable click to upload.
  380. no_drag: Whether to disable drag and drop.
  381. no_keyboard: Whether to disable using the space/enter keys to upload.
  382. style: The style of the component.
  383. key: A unique key for the component.
  384. id: The id for the component.
  385. class_name: The class name for the component.
  386. autofocus: Whether the component should take the focus once the page is loaded
  387. custom_attrs: custom attribute
  388. **props: The properties of the component.
  389. Returns:
  390. The styled upload component.
  391. """
  392. ...
  393. upload = UploadNamespace()