upload.pyi 17 KB

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