upload.pyi 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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, ClassVar, Dict, List, Optional, Union, overload
  7. from reflex.components.base.fragment import Fragment
  8. from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
  9. from reflex.constants import Dirs
  10. from reflex.event import BASE_STATE, CallableEventSpec, EventSpec, EventType
  11. from reflex.style import Style
  12. from reflex.utils.imports import ImportVar
  13. from reflex.vars import VarData
  14. from reflex.vars.base import CallableVar, Var
  15. DEFAULT_UPLOAD_ID: str
  16. upload_files_context_var_data: VarData
  17. @CallableVar
  18. def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
  19. @CallableVar
  20. def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
  21. @CallableEventSpec
  22. def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ...
  23. def cancel_upload(upload_id: str) -> EventSpec: ...
  24. def get_upload_dir() -> Path: ...
  25. uploaded_files_url_prefix = Var(
  26. _js_expr="getBackendURL(env.UPLOAD)",
  27. _var_data=VarData(
  28. imports={
  29. f"$/{Dirs.STATE_PATH}": "getBackendURL",
  30. "$/env.json": ImportVar(tag="env", is_default=True),
  31. }
  32. ),
  33. ).to(str)
  34. def get_upload_url(file_path: str) -> Var[str]: ...
  35. class UploadFilesProvider(Component):
  36. @overload
  37. @classmethod
  38. def create( # type: ignore
  39. cls,
  40. *children,
  41. style: Optional[Style] = None,
  42. key: Optional[Any] = None,
  43. id: Optional[Any] = None,
  44. class_name: Optional[Any] = None,
  45. autofocus: Optional[bool] = None,
  46. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  47. on_blur: Optional[EventType[[], BASE_STATE]] = None,
  48. on_click: Optional[EventType[[], BASE_STATE]] = None,
  49. on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
  50. on_double_click: Optional[EventType[[], BASE_STATE]] = None,
  51. on_focus: Optional[EventType[[], BASE_STATE]] = None,
  52. on_mount: Optional[EventType[[], BASE_STATE]] = None,
  53. on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
  54. on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
  55. on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
  56. on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
  57. on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
  58. on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
  59. on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
  60. on_scroll: Optional[EventType[[], BASE_STATE]] = None,
  61. on_unmount: Optional[EventType[[], BASE_STATE]] = None,
  62. **props,
  63. ) -> "UploadFilesProvider":
  64. """Create the component.
  65. Args:
  66. *children: The children of the component.
  67. style: The style of the component.
  68. key: A unique key for the component.
  69. id: The id for the component.
  70. class_name: The class name for the component.
  71. autofocus: Whether the component should take the focus once the page is loaded
  72. custom_attrs: custom attribute
  73. **props: The props of the component.
  74. Returns:
  75. The component.
  76. """
  77. ...
  78. class GhostUpload(Fragment):
  79. @overload
  80. @classmethod
  81. def create( # type: ignore
  82. cls,
  83. *children,
  84. style: Optional[Style] = None,
  85. key: Optional[Any] = None,
  86. id: Optional[Any] = None,
  87. class_name: Optional[Any] = None,
  88. autofocus: Optional[bool] = None,
  89. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  90. on_blur: Optional[EventType[[], BASE_STATE]] = None,
  91. on_click: Optional[EventType[[], BASE_STATE]] = None,
  92. on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
  93. on_double_click: Optional[EventType[[], BASE_STATE]] = None,
  94. on_drop: Optional[
  95. Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
  96. ] = None,
  97. on_focus: Optional[EventType[[], BASE_STATE]] = None,
  98. on_mount: Optional[EventType[[], BASE_STATE]] = None,
  99. on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
  100. on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
  101. on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
  102. on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
  103. on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
  104. on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
  105. on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
  106. on_scroll: Optional[EventType[[], BASE_STATE]] = None,
  107. on_unmount: Optional[EventType[[], BASE_STATE]] = None,
  108. **props,
  109. ) -> "GhostUpload":
  110. """Create the component.
  111. Args:
  112. *children: The children of the component.
  113. on_drop: Fired when files are dropped.
  114. style: The style of the component.
  115. key: A unique key for the component.
  116. id: The id for the component.
  117. class_name: The class name for the component.
  118. autofocus: Whether the component should take the focus once the page is loaded
  119. custom_attrs: custom attribute
  120. **props: The props of the component.
  121. Returns:
  122. The component.
  123. """
  124. ...
  125. class Upload(MemoizationLeaf):
  126. is_used: ClassVar[bool] = False
  127. @overload
  128. @classmethod
  129. def create( # type: ignore
  130. cls,
  131. *children,
  132. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  133. disabled: Optional[Union[Var[bool], bool]] = None,
  134. max_files: Optional[Union[Var[int], int]] = None,
  135. max_size: Optional[Union[Var[int], int]] = None,
  136. min_size: Optional[Union[Var[int], int]] = None,
  137. multiple: Optional[Union[Var[bool], bool]] = None,
  138. no_click: Optional[Union[Var[bool], bool]] = None,
  139. no_drag: Optional[Union[Var[bool], bool]] = None,
  140. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  141. style: Optional[Style] = None,
  142. key: Optional[Any] = None,
  143. id: Optional[Any] = None,
  144. class_name: Optional[Any] = None,
  145. autofocus: Optional[bool] = None,
  146. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  147. on_blur: Optional[EventType[[], BASE_STATE]] = None,
  148. on_click: Optional[EventType[[], BASE_STATE]] = None,
  149. on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
  150. on_double_click: Optional[EventType[[], BASE_STATE]] = None,
  151. on_drop: Optional[
  152. Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
  153. ] = None,
  154. on_focus: Optional[EventType[[], BASE_STATE]] = None,
  155. on_mount: Optional[EventType[[], BASE_STATE]] = None,
  156. on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
  157. on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
  158. on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
  159. on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
  160. on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
  161. on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
  162. on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
  163. on_scroll: Optional[EventType[[], BASE_STATE]] = None,
  164. on_unmount: Optional[EventType[[], BASE_STATE]] = None,
  165. **props,
  166. ) -> "Upload":
  167. """Create an upload component.
  168. Args:
  169. *children: The children of the component.
  170. 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
  171. disabled: Whether the dropzone is disabled.
  172. max_files: The maximum number of files that can be uploaded.
  173. max_size: The maximum file size (bytes) that can be uploaded.
  174. min_size: The minimum file size (bytes) that can be uploaded.
  175. multiple: Whether to allow multiple files to be uploaded.
  176. no_click: Whether to disable click to upload.
  177. no_drag: Whether to disable drag and drop.
  178. no_keyboard: Whether to disable using the space/enter keys to upload.
  179. on_drop: Fired when files are dropped.
  180. style: The style of the component.
  181. key: A unique key for the component.
  182. id: The id for the component.
  183. class_name: The class name for the component.
  184. autofocus: Whether the component should take the focus once the page is loaded
  185. custom_attrs: custom attribute
  186. **props: The properties of the component.
  187. Returns:
  188. The upload component.
  189. """
  190. ...
  191. class StyledUpload(Upload):
  192. @overload
  193. @classmethod
  194. def create( # type: ignore
  195. cls,
  196. *children,
  197. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  198. disabled: Optional[Union[Var[bool], bool]] = None,
  199. max_files: Optional[Union[Var[int], int]] = None,
  200. max_size: Optional[Union[Var[int], int]] = None,
  201. min_size: Optional[Union[Var[int], int]] = None,
  202. multiple: Optional[Union[Var[bool], bool]] = None,
  203. no_click: Optional[Union[Var[bool], bool]] = None,
  204. no_drag: Optional[Union[Var[bool], bool]] = None,
  205. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  206. style: Optional[Style] = None,
  207. key: Optional[Any] = None,
  208. id: Optional[Any] = None,
  209. class_name: Optional[Any] = None,
  210. autofocus: Optional[bool] = None,
  211. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  212. on_blur: Optional[EventType[[], BASE_STATE]] = None,
  213. on_click: Optional[EventType[[], BASE_STATE]] = None,
  214. on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
  215. on_double_click: Optional[EventType[[], BASE_STATE]] = None,
  216. on_drop: Optional[
  217. Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
  218. ] = None,
  219. on_focus: Optional[EventType[[], BASE_STATE]] = None,
  220. on_mount: Optional[EventType[[], BASE_STATE]] = None,
  221. on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
  222. on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
  223. on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
  224. on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
  225. on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
  226. on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
  227. on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
  228. on_scroll: Optional[EventType[[], BASE_STATE]] = None,
  229. on_unmount: Optional[EventType[[], BASE_STATE]] = None,
  230. **props,
  231. ) -> "StyledUpload":
  232. """Create the styled upload component.
  233. Args:
  234. *children: The children of the component.
  235. 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
  236. disabled: Whether the dropzone is disabled.
  237. max_files: The maximum number of files that can be uploaded.
  238. max_size: The maximum file size (bytes) that can be uploaded.
  239. min_size: The minimum file size (bytes) that can be uploaded.
  240. multiple: Whether to allow multiple files to be uploaded.
  241. no_click: Whether to disable click to upload.
  242. no_drag: Whether to disable drag and drop.
  243. no_keyboard: Whether to disable using the space/enter keys to upload.
  244. on_drop: Fired when files are dropped.
  245. style: The style of the component.
  246. key: A unique key for the component.
  247. id: The id for the component.
  248. class_name: The class name for the component.
  249. autofocus: Whether the component should take the focus once the page is loaded
  250. custom_attrs: custom attribute
  251. **props: The properties of the component.
  252. Returns:
  253. The styled upload component.
  254. """
  255. ...
  256. class UploadNamespace(ComponentNamespace):
  257. root = Upload.create
  258. @staticmethod
  259. def __call__(
  260. *children,
  261. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  262. disabled: Optional[Union[Var[bool], bool]] = None,
  263. max_files: Optional[Union[Var[int], int]] = None,
  264. max_size: Optional[Union[Var[int], int]] = None,
  265. min_size: Optional[Union[Var[int], int]] = None,
  266. multiple: Optional[Union[Var[bool], bool]] = None,
  267. no_click: Optional[Union[Var[bool], bool]] = None,
  268. no_drag: Optional[Union[Var[bool], bool]] = None,
  269. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  270. style: Optional[Style] = None,
  271. key: Optional[Any] = None,
  272. id: Optional[Any] = None,
  273. class_name: Optional[Any] = None,
  274. autofocus: Optional[bool] = None,
  275. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  276. on_blur: Optional[EventType[[], BASE_STATE]] = None,
  277. on_click: Optional[EventType[[], BASE_STATE]] = None,
  278. on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
  279. on_double_click: Optional[EventType[[], BASE_STATE]] = None,
  280. on_drop: Optional[
  281. Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
  282. ] = None,
  283. on_focus: Optional[EventType[[], BASE_STATE]] = None,
  284. on_mount: Optional[EventType[[], BASE_STATE]] = None,
  285. on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
  286. on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
  287. on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
  288. on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
  289. on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
  290. on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
  291. on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
  292. on_scroll: Optional[EventType[[], BASE_STATE]] = None,
  293. on_unmount: Optional[EventType[[], BASE_STATE]] = None,
  294. **props,
  295. ) -> "StyledUpload":
  296. """Create the styled upload component.
  297. Args:
  298. *children: The children of the component.
  299. 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
  300. disabled: Whether the dropzone is disabled.
  301. max_files: The maximum number of files that can be uploaded.
  302. max_size: The maximum file size (bytes) that can be uploaded.
  303. min_size: The minimum file size (bytes) that can be uploaded.
  304. multiple: Whether to allow multiple files to be uploaded.
  305. no_click: Whether to disable click to upload.
  306. no_drag: Whether to disable drag and drop.
  307. no_keyboard: Whether to disable using the space/enter keys to upload.
  308. on_drop: Fired when files are dropped.
  309. style: The style of the component.
  310. key: A unique key for the component.
  311. id: The id for the component.
  312. class_name: The class name for the component.
  313. autofocus: Whether the component should take the focus once the page is loaded
  314. custom_attrs: custom attribute
  315. **props: The properties of the component.
  316. Returns:
  317. The styled upload component.
  318. """
  319. ...
  320. upload = UploadNamespace()