upload.pyi 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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.style import Style
  15. from reflex.utils.imports import ImportVar
  16. from reflex.vars import VarData
  17. from reflex.vars.base import CallableVar, Var
  18. DEFAULT_UPLOAD_ID: str
  19. upload_files_context_var_data: VarData
  20. @CallableVar
  21. def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
  22. @CallableVar
  23. def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
  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 = Var(
  29. _js_expr="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[Var, str]]] = None,
  50. on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  51. on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  52. on_context_menu: Optional[
  53. Union[EventHandler, EventSpec, list, Callable, Var]
  54. ] = None,
  55. on_double_click: Optional[
  56. Union[EventHandler, EventSpec, list, Callable, Var]
  57. ] = None,
  58. on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  59. on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  60. on_mouse_down: Optional[
  61. Union[EventHandler, EventSpec, list, Callable, Var]
  62. ] = None,
  63. on_mouse_enter: Optional[
  64. Union[EventHandler, EventSpec, list, Callable, Var]
  65. ] = None,
  66. on_mouse_leave: Optional[
  67. Union[EventHandler, EventSpec, list, Callable, Var]
  68. ] = None,
  69. on_mouse_move: Optional[
  70. Union[EventHandler, EventSpec, list, Callable, Var]
  71. ] = None,
  72. on_mouse_out: Optional[
  73. Union[EventHandler, EventSpec, list, Callable, Var]
  74. ] = None,
  75. on_mouse_over: Optional[
  76. Union[EventHandler, EventSpec, list, Callable, Var]
  77. ] = None,
  78. on_mouse_up: Optional[
  79. Union[EventHandler, EventSpec, list, Callable, Var]
  80. ] = None,
  81. on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  82. on_unmount: Optional[
  83. Union[EventHandler, EventSpec, list, Callable, Var]
  84. ] = None,
  85. **props,
  86. ) -> "UploadFilesProvider":
  87. """Create the component.
  88. Args:
  89. *children: The children of the component.
  90. style: The style of the component.
  91. key: A unique key for the component.
  92. id: The id for the component.
  93. class_name: The class name for the component.
  94. autofocus: Whether the component should take the focus once the page is loaded
  95. custom_attrs: custom attribute
  96. **props: The props of the component.
  97. Returns:
  98. The component.
  99. """
  100. ...
  101. class Upload(MemoizationLeaf):
  102. is_used: ClassVar[bool] = False
  103. @overload
  104. @classmethod
  105. def create( # type: ignore
  106. cls,
  107. *children,
  108. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  109. disabled: Optional[Union[Var[bool], bool]] = None,
  110. max_files: Optional[Union[Var[int], int]] = None,
  111. max_size: Optional[Union[Var[int], int]] = None,
  112. min_size: Optional[Union[Var[int], int]] = None,
  113. multiple: Optional[Union[Var[bool], bool]] = None,
  114. no_click: Optional[Union[Var[bool], bool]] = None,
  115. no_drag: Optional[Union[Var[bool], bool]] = None,
  116. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  117. style: Optional[Style] = None,
  118. key: Optional[Any] = None,
  119. id: Optional[Any] = None,
  120. class_name: Optional[Any] = None,
  121. autofocus: Optional[bool] = None,
  122. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  123. on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  124. on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  125. on_context_menu: Optional[
  126. Union[EventHandler, EventSpec, list, Callable, Var]
  127. ] = None,
  128. on_double_click: Optional[
  129. Union[EventHandler, EventSpec, list, Callable, Var]
  130. ] = None,
  131. on_drop: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  132. on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  133. on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  134. on_mouse_down: Optional[
  135. Union[EventHandler, EventSpec, list, Callable, Var]
  136. ] = None,
  137. on_mouse_enter: Optional[
  138. Union[EventHandler, EventSpec, list, Callable, Var]
  139. ] = None,
  140. on_mouse_leave: Optional[
  141. Union[EventHandler, EventSpec, list, Callable, Var]
  142. ] = None,
  143. on_mouse_move: Optional[
  144. Union[EventHandler, EventSpec, list, Callable, Var]
  145. ] = None,
  146. on_mouse_out: Optional[
  147. Union[EventHandler, EventSpec, list, Callable, Var]
  148. ] = None,
  149. on_mouse_over: Optional[
  150. Union[EventHandler, EventSpec, list, Callable, Var]
  151. ] = None,
  152. on_mouse_up: Optional[
  153. Union[EventHandler, EventSpec, list, Callable, Var]
  154. ] = None,
  155. on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  156. on_unmount: Optional[
  157. Union[EventHandler, EventSpec, list, Callable, Var]
  158. ] = None,
  159. **props,
  160. ) -> "Upload":
  161. """Create an upload component.
  162. Args:
  163. *children: The children of the component.
  164. 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
  165. disabled: Whether the dropzone is disabled.
  166. max_files: The maximum number of files that can be uploaded.
  167. max_size: The maximum file size (bytes) that can be uploaded.
  168. min_size: The minimum file size (bytes) that can be uploaded.
  169. multiple: Whether to allow multiple files to be uploaded.
  170. no_click: Whether to disable click to upload.
  171. no_drag: Whether to disable drag and drop.
  172. no_keyboard: Whether to disable using the space/enter keys to upload.
  173. style: The style of the component.
  174. key: A unique key for the component.
  175. id: The id for the component.
  176. class_name: The class name for the component.
  177. autofocus: Whether the component should take the focus once the page is loaded
  178. custom_attrs: custom attribute
  179. **props: The properties of the component.
  180. Returns:
  181. The upload component.
  182. """
  183. ...
  184. class StyledUpload(Upload):
  185. @overload
  186. @classmethod
  187. def create( # type: ignore
  188. cls,
  189. *children,
  190. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  191. disabled: Optional[Union[Var[bool], bool]] = None,
  192. max_files: Optional[Union[Var[int], int]] = None,
  193. max_size: Optional[Union[Var[int], int]] = None,
  194. min_size: Optional[Union[Var[int], int]] = None,
  195. multiple: Optional[Union[Var[bool], bool]] = None,
  196. no_click: Optional[Union[Var[bool], bool]] = None,
  197. no_drag: Optional[Union[Var[bool], bool]] = None,
  198. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  199. style: Optional[Style] = None,
  200. key: Optional[Any] = None,
  201. id: Optional[Any] = None,
  202. class_name: Optional[Any] = None,
  203. autofocus: Optional[bool] = None,
  204. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  205. on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  206. on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  207. on_context_menu: Optional[
  208. Union[EventHandler, EventSpec, list, Callable, Var]
  209. ] = None,
  210. on_double_click: Optional[
  211. Union[EventHandler, EventSpec, list, Callable, Var]
  212. ] = None,
  213. on_drop: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  214. on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  215. on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  216. on_mouse_down: Optional[
  217. Union[EventHandler, EventSpec, list, Callable, Var]
  218. ] = None,
  219. on_mouse_enter: Optional[
  220. Union[EventHandler, EventSpec, list, Callable, Var]
  221. ] = None,
  222. on_mouse_leave: Optional[
  223. Union[EventHandler, EventSpec, list, Callable, Var]
  224. ] = None,
  225. on_mouse_move: Optional[
  226. Union[EventHandler, EventSpec, list, Callable, Var]
  227. ] = None,
  228. on_mouse_out: Optional[
  229. Union[EventHandler, EventSpec, list, Callable, Var]
  230. ] = None,
  231. on_mouse_over: Optional[
  232. Union[EventHandler, EventSpec, list, Callable, Var]
  233. ] = None,
  234. on_mouse_up: Optional[
  235. Union[EventHandler, EventSpec, list, Callable, Var]
  236. ] = None,
  237. on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  238. on_unmount: Optional[
  239. Union[EventHandler, EventSpec, list, Callable, Var]
  240. ] = None,
  241. **props,
  242. ) -> "StyledUpload":
  243. """Create the styled upload component.
  244. Args:
  245. *children: The children of the component.
  246. 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
  247. disabled: Whether the dropzone is disabled.
  248. max_files: The maximum number of files that can be uploaded.
  249. max_size: The maximum file size (bytes) that can be uploaded.
  250. min_size: The minimum file size (bytes) that can be uploaded.
  251. multiple: Whether to allow multiple files to be uploaded.
  252. no_click: Whether to disable click to upload.
  253. no_drag: Whether to disable drag and drop.
  254. no_keyboard: Whether to disable using the space/enter keys to upload.
  255. style: The style of the component.
  256. key: A unique key for the component.
  257. id: The id for the component.
  258. class_name: The class name for the component.
  259. autofocus: Whether the component should take the focus once the page is loaded
  260. custom_attrs: custom attribute
  261. **props: The properties of the component.
  262. Returns:
  263. The styled upload component.
  264. """
  265. ...
  266. class UploadNamespace(ComponentNamespace):
  267. root = Upload.create
  268. @staticmethod
  269. def __call__(
  270. *children,
  271. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  272. disabled: Optional[Union[Var[bool], bool]] = None,
  273. max_files: Optional[Union[Var[int], int]] = None,
  274. max_size: Optional[Union[Var[int], int]] = None,
  275. min_size: Optional[Union[Var[int], int]] = None,
  276. multiple: Optional[Union[Var[bool], bool]] = None,
  277. no_click: Optional[Union[Var[bool], bool]] = None,
  278. no_drag: Optional[Union[Var[bool], bool]] = None,
  279. no_keyboard: Optional[Union[Var[bool], bool]] = 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[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  287. on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  288. on_context_menu: Optional[
  289. Union[EventHandler, EventSpec, list, Callable, Var]
  290. ] = None,
  291. on_double_click: Optional[
  292. Union[EventHandler, EventSpec, list, Callable, Var]
  293. ] = None,
  294. on_drop: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  295. on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  296. on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  297. on_mouse_down: Optional[
  298. Union[EventHandler, EventSpec, list, Callable, Var]
  299. ] = None,
  300. on_mouse_enter: Optional[
  301. Union[EventHandler, EventSpec, list, Callable, Var]
  302. ] = None,
  303. on_mouse_leave: Optional[
  304. Union[EventHandler, EventSpec, list, Callable, Var]
  305. ] = None,
  306. on_mouse_move: Optional[
  307. Union[EventHandler, EventSpec, list, Callable, Var]
  308. ] = None,
  309. on_mouse_out: Optional[
  310. Union[EventHandler, EventSpec, list, Callable, Var]
  311. ] = None,
  312. on_mouse_over: Optional[
  313. Union[EventHandler, EventSpec, list, Callable, Var]
  314. ] = None,
  315. on_mouse_up: Optional[
  316. Union[EventHandler, EventSpec, list, Callable, Var]
  317. ] = None,
  318. on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
  319. on_unmount: Optional[
  320. Union[EventHandler, EventSpec, list, Callable, Var]
  321. ] = None,
  322. **props,
  323. ) -> "StyledUpload":
  324. """Create the styled upload component.
  325. Args:
  326. *children: The children of the component.
  327. 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
  328. disabled: Whether the dropzone is disabled.
  329. max_files: The maximum number of files that can be uploaded.
  330. max_size: The maximum file size (bytes) that can be uploaded.
  331. min_size: The minimum file size (bytes) that can be uploaded.
  332. multiple: Whether to allow multiple files to be uploaded.
  333. no_click: Whether to disable click to upload.
  334. no_drag: Whether to disable drag and drop.
  335. no_keyboard: Whether to disable using the space/enter keys to upload.
  336. style: The style of the component.
  337. key: A unique key for the component.
  338. id: The id for the component.
  339. class_name: The class name for the component.
  340. autofocus: Whether the component should take the focus once the page is loaded
  341. custom_attrs: custom attribute
  342. **props: The properties of the component.
  343. Returns:
  344. The styled upload component.
  345. """
  346. ...
  347. upload = UploadNamespace()