1
0

upload.pyi 17 KB

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